PasteSpecial Paste:=ColumnWidths

A

Arvi Laanemets

Hi

When I record PasteSpecial operation as macro, I get a code like this:
Range(RangeToCopy).Select
Selection.Copy
Range(RangeToPaste).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Selection.PasteSpecial Paste:=xlColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

As I prefer to work wihout pouncing around with cursor, my code looks like
this instead:
Range(RangeToCopy).Copy
Range(RangeToPaste).PasteSpecial Paste:=xlValues
Range(RangeToPaste).PasteSpecial Paste:=xlFormats
' so long it works fine, but next row of code does fail
Range(RangeToPaste).PasteSpecial Paste:=xlColumnWidths

I think, that like with copying the validation, where I have to use an index
6 instead of optional variant's name , I need some index here too. Has
someone some knowledge about this - in Excel Help I didn't find anything
useful about this matter.

Thanks in advance
 
R

Ron de Bruin

Importent : because of another Bug

First pastespecial the ColumnWidths then the values and formats in the code
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top