Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copying formats - column widths, formats, outlining to worksheets | Excel Worksheet Functions | |||
Copying rows values on one sheet to part of a formula in a column | Excel Discussion (Misc queries) | |||
Copying Part of a row down part of a column | Excel Discussion (Misc queries) | |||
copying conditional formats to a whole column | Excel Worksheet Functions | |||
Copying formulas, formats, and sheet names across workbooks | Excel Programming |