ColumnWidths in code


Posted by Tim on January 11, 2002 8:44 AM

This is probably an easy question, but I'm here at work and my VBA books are at home.

I am writing some code in which I wanted to PasteSpecial Column Widths. I wasn't getting it correct so I used the Macro Recorder to see what I was doing wrong. When I inserted its code into mine, it still didn't work.

HERE IS THE KICKER> When I simply run the Macro that was recorded, IT DOESN'T WORK! What is going on?



Posted by Tom Urtis on January 11, 2002 9:00 AM

In answer to your question, what's going on is that some VBA instructions are unrecordable, and simply must be typed directly into the module.

Try adding something like this to your macro:

Columns("D:D").ColumnWidth = Columns("A:A").ColumnWidth

Where Column A contains the column width you want to "copy", and column D is the destination column.

Tom Urtis