![]() |
Selecting a Column
I am running a VBA application and after I have copied data to a worksheet,
I want to copy the column formatting from column N to column N+1. The following code, first line gives me a 'Select method of Range class failed'. 'Column' is an Integer number. ' Detail_Report.Columns(Column).Select ' Application.CutCopyMode = False ' Selection.Copy ' Detail_Report.Columns(Column + 1).Select ' Selection.PasteSpecial Paste:=xlPasteFormats What am I doing wrong? Thanks, |
Selecting a Column
Make the DIM is correct and that Activate preceeds Select:
Sub dural() Dim Column As Integer Dim Detailed_Report As Worksheet Set Detailed_Report = Sheets("Sheet1") Column = 3 Detailed_Report.Activate Columns(Column).Select End Sub -- Gary''s Student - gsnu200903 "William Wolfe" wrote: I am running a VBA application and after I have copied data to a worksheet, I want to copy the column formatting from column N to column N+1. The following code, first line gives me a 'Select method of Range class failed'. 'Column' is an Integer number. ' Detail_Report.Columns(Column).Select ' Application.CutCopyMode = False ' Selection.Copy ' Detail_Report.Columns(Column + 1).Select ' Selection.PasteSpecial Paste:=xlPasteFormats What am I doing wrong? Thanks, |
Selecting a Column
Why don't you do a direct copy (rather than Copy/Paste Special)... it will
copy the values and the formatting. For example, Detail_Report.Columns(Column).Copy Range("C1") Note that you do not specify the entire column in the destination, only the first cell of the range being copied to. You can also do this for smaller ranges as well. For example... Range("A1:E5").Copy Range("M7") -- Rick (MVP - Excel) "William Wolfe" wrote in message ... I am running a VBA application and after I have copied data to a worksheet, I want to copy the column formatting from column N to column N+1. The following code, first line gives me a 'Select method of Range class failed'. 'Column' is an Integer number. ' Detail_Report.Columns(Column).Select ' Application.CutCopyMode = False ' Selection.Copy ' Detail_Report.Columns(Column + 1).Select ' Selection.PasteSpecial Paste:=xlPasteFormats What am I doing wrong? Thanks, |
All times are GMT +1. The time now is 07:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com