xlColumnWidths Bug

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

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
Posted in Uncategorized

One thought on “xlColumnWidths Bug


Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.