ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   PasteSpecial Paste:=ColumnWidths (https://www.excelbanter.com/excel-programming/322630-pastespecial-paste-%3Dcolumnwidths.html)

Arvi Laanemets

PasteSpecial Paste:=ColumnWidths
 
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

--
When sending mail, use address arvil<attarkon.ee
Arvi Laanemets



Ron de Bruin

PasteSpecial Paste:=ColumnWidths
 
Hi Arvi

Paste:=8



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Arvi Laanemets" wrote in message ...
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

--
When sending mail, use address arvil<attarkon.ee
Arvi Laanemets





Ron de Bruin

PasteSpecial Paste:=ColumnWidths
 
Importent : because of another Bug

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


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Ron de Bruin" wrote in message ...
Hi Arvi

Paste:=8



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Arvi Laanemets" wrote in message ...
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

--
When sending mail, use address arvil<attarkon.ee
Arvi Laanemets







Arvi Laanemets

PasteSpecial Paste:=ColumnWidths
 
Thanks!

--
When sending mail, use address arvil<attarkon.ee
Arvi Laanemets




All times are GMT +1. The time now is 10:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com