ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy/Paste Macro and Column Sizing (https://www.excelbanter.com/excel-programming/308216-copy-paste-macro-column-sizing.html)

JimK

Copy/Paste Macro and Column Sizing
 
Hi,
I've written a simple macro that copy/pastes a specific range from a source
worksheet to a new worksheet. It copy/pastes as values and formats in order
to eliminate formulas and maintain the source formatting. However, I can't
get the column widths to copy over as well. I can't just copy/paste the
whole column becuse the source range can be variable, and it's not the whole
column (there's data below that I don't want to copy/paste). How do I
copy/paste the column widths of a user defined cell range? The user is
defining the cell range by highlighting the range and then running the macro.
Any help would be greatly appreciated. Thanks.

Frank Kabel

Copy/Paste Macro and Column Sizing
 
Hi
try reading the columnwidth property of the selected range and set this
width for the target location within your macro

--
Regards
Frank Kabel
Frankfurt, Germany

"JimK" schrieb im Newsbeitrag
...
Hi,
I've written a simple macro that copy/pastes a specific range from a

source
worksheet to a new worksheet. It copy/pastes as values and formats

in order
to eliminate formulas and maintain the source formatting. However, I

can't
get the column widths to copy over as well. I can't just copy/paste

the
whole column becuse the source range can be variable, and it's not

the whole
column (there's data below that I don't want to copy/paste). How do I
copy/paste the column widths of a user defined cell range? The user

is
defining the cell range by highlighting the range and then running

the macro.
Any help would be greatly appreciated. Thanks.



Tom Ogilvy

Copy/Paste Macro and Column Sizing
 
Range("DestinationRange").PasteSpecial 8

if you have excel 2000 or later.

--
Regards,
Tom Ogilvy

"JimK" wrote in message
...
Hi,
I've written a simple macro that copy/pastes a specific range from a

source
worksheet to a new worksheet. It copy/pastes as values and formats in

order
to eliminate formulas and maintain the source formatting. However, I

can't
get the column widths to copy over as well. I can't just copy/paste the
whole column becuse the source range can be variable, and it's not the

whole
column (there's data below that I don't want to copy/paste). How do I
copy/paste the column widths of a user defined cell range? The user is
defining the cell range by highlighting the range and then running the

macro.
Any help would be greatly appreciated. Thanks.





All times are GMT +1. The time now is 08:58 AM.

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