![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
When I copy a worksheet and then paste it to another, some formatting doesn't follow. ex. column width etc. What code do I use to make the column width paste too. Used this code to copy.
Worksheets("template").UsedRange.SpecialCells(xlCellTypeVisible).Copy Worksheets(2).Activate Range("A1").Select ActiveSheet.Paste |
|
|
|
#2 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
It's a separate procedure, add the code to the end of your current procedure. May make your workbook big:
application.screenupdating = false Worksheets("template").Cells.Select Selection.Copy [a1].select Worksheets(2).Activate Cells.Select Selection.PasteSpecial Paste:=xlFormats [a1].select application.screenupdating = true Cheers, Nate [ This Message was edited by: NateO on 2002-03-12 16:23 ] |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
To paste the column widths use this
Const xlColumnWidths = 8 Selection.PasteSpecial Paste:=xlColumnWidths OR Selection.PasteSpecial Paste:=8 Ivan |
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
The pastespecial xlcoulmnwidths does not work properly in excel2000. Try it and see ie record a macro using the pastespecial columnwidths. Then run it.....you will receive and error. The code I gave is a work around to this problem. Ivan |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|