Mike asks
…But when you try to do Selection.PasteSpecial Paste:=xlColumnWidths and try to run the macro, Excel say xlColumnWidths is undefined. Strange, since this is what the macro recorder gave me. …
I can honestly say that I’ve never pasted special column widths before. In fact, I didn’t even know it was an option. But Mike did indeed discover a bug that MS describes in KB231090. When I recorded a macro, I got
Sub Macro1()
‘
‘ Macro1 Macro
‘ Macro recorded 6/13/2005 by Dick Kusleika
‘
‘
Selection.Copy
Range(“E1”).Select
Selection.PasteSpecial Paste:=xlcolumnwidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub
‘
‘ Macro1 Macro
‘ Macro recorded 6/13/2005 by Dick Kusleika
‘
‘
Selection.Copy
Range(“E1”).Select
Selection.PasteSpecial Paste:=xlcolumnwidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub
But it looks like the Excel guys forgot to create the constant xlColumnWidths. Use it’s intended literal value, 8, instead, e.g.
Selection.PasteSpecial Paste:=8
Hi all
There is also a problem if you use xlPasteValidation
Use 6 then