![]() |
Getting a Select Range class field during a macro setup
I am a very newbie to Visual Basic. What I am trying to do is automate a
journal file conversion process via Excel worksheets. I want on Sheet2 to remove column T when column T equals 01/01/1900, but before we add the if statement I simply want to just delete the column. The macro works well if I am on sheet2 Columns("T:T").Select Selection.Delete Shift:=xlToLeft But if I do this Sheet2.Columns("T:T").Select Selection.Delete Shift:=xlToLeft Then I get this error Run-time error 1004 Select method of Range class failed This is so stupid simple I am missing something...now I realize I do not have the 'If column T = 1/1/1900. I am just trying to delete the column regardless of the condition from another sheet in the workbook. thanks |
Getting a Select Range class field during a macro setup
Avoid selecting the range and all will be well. In order to select a range on
a specific sheet you first have to select the sheet (which you probably have not done). Try this Sheet2.Columns("T:T").Delete Shift:=xlToLeft Since there is no selecting there should be no problem. -- HTH... Jim Thomlinson "ssciarrino" wrote: I am a very newbie to Visual Basic. What I am trying to do is automate a journal file conversion process via Excel worksheets. I want on Sheet2 to remove column T when column T equals 01/01/1900, but before we add the if statement I simply want to just delete the column. The macro works well if I am on sheet2 Columns("T:T").Select Selection.Delete Shift:=xlToLeft But if I do this Sheet2.Columns("T:T").Select Selection.Delete Shift:=xlToLeft Then I get this error Run-time error 1004 Select method of Range class failed This is so stupid simple I am missing something...now I realize I do not have the 'If column T = 1/1/1900. I am just trying to delete the column regardless of the condition from another sheet in the workbook. thanks |
All times are GMT +1. The time now is 12:42 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com