Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default VBA code for copying part of a sheet to another, with column widthsand formats

Hello,
I'm trying to take a range from one
sheet(Range.cells(1,1),cells(10,10)) and copy it from sheet 1 to sheet
2. The copy is easy. But what I don't understand how to do is to
carry over with the copy all of the column widths and numeric
formats. Can someone please explain how this is done in VBA code?

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default VBA code for copying part of a sheet to another, with column width

The column widths are a seperate Paste Special operation.

Something like this will work

Sub test()
Sheets("Sheet1").Activate
Range(Cells(1, 1), Cells(10, 10)).Copy
Sheets("Sheet2").Activate
Range(Cells(1, 1), Cells(10, 10)).Select
Selection.PasteSpecial Paste:=xlPasteFormulasAndNumberFormats
Selection.PasteSpecial Paste:=xlPasteColumnWidths
End Sub

If you want values instead of formulas use xlPasteValuesAndNumberFormats
instead of xlPasteFormulasAndNumberFormats. Using xlPasteAll instead of
xlPasteFormulasAndNumberFormats will copy the fonts, shading etc (but still
not the column width, this has to be seperate)
--
If this helps, please remember to click yes.


"Andrew" wrote:

Hello,
I'm trying to take a range from one
sheet(Range.cells(1,1),cells(10,10)) and copy it from sheet 1 to sheet
2. The copy is easy. But what I don't understand how to do is to
carry over with the copy all of the column widths and numeric
formats. Can someone please explain how this is done in VBA code?

thanks
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying formats - column widths, formats, outlining to worksheets DavidBr318 Excel Worksheet Functions 4 August 14th 09 05:03 AM
Copying rows values on one sheet to part of a formula in a column Manosh Excel Discussion (Misc queries) 3 June 23rd 09 03:37 PM
Copying Part of a row down part of a column Not Excelling Excel Discussion (Misc queries) 3 January 6th 06 11:58 PM
copying conditional formats to a whole column Markitos Excel Worksheet Functions 0 November 1st 04 11:23 PM
Copying formulas, formats, and sheet names across workbooks Kevin H. Stecyk[_2_] Excel Programming 7 August 22nd 04 09:50 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"