![]() |
"Select" and "Activate" failing?
I have a Workbook_Open macro as follows:
Private Sub Workbook_Open() Worksheets("Sheet2").Visible = True Worksheets("Sheet3").Visible = xlVeryHidden Worksheets("Sheet1").Visible = True Worksheets("Sheet1").Range("A1").Select End Sub The last line fails with " "Select" method of "Range" class failed." I then changed it to Worksheets("Sheet1").Range("A1").Activate and got the same failure error. Why? Ed |
"Select" and "Activate" failing?
I don't know why but the work around I use is:
Application.GoTo Sheets("Sheet1").Range("A1") Charles Ed wrote: I have a Workbook_Open macro as follows: Private Sub Workbook_Open() Worksheets("Sheet2").Visible = True Worksheets("Sheet3").Visible = xlVeryHidden Worksheets("Sheet1").Visible = True Worksheets("Sheet1").Range("A1").Select End Sub The last line fails with " "Select" method of "Range" class failed." I then changed it to Worksheets("Sheet1").Range("A1").Activate and got the same failure error. Why? Ed |
"Select" and "Activate" failing?
or you can use the following two lines
Worksheets("Sheet1").activate Worksheets("Sheet1").Range("A1").Select You can not select a range unless that sheet is already activated(selected) Hope this helps. Die_Another_Day wrote: I don't know why but the work around I use is: Application.GoTo Sheets("Sheet1").Range("A1") Charles Ed wrote: I have a Workbook_Open macro as follows: Private Sub Workbook_Open() Worksheets("Sheet2").Visible = True Worksheets("Sheet3").Visible = xlVeryHidden Worksheets("Sheet1").Visible = True Worksheets("Sheet1").Range("A1").Select End Sub The last line fails with " "Select" method of "Range" class failed." I then changed it to Worksheets("Sheet1").Range("A1").Activate and got the same failure error. Why? Ed |
"Select" and "Activate" failing?
Thank you, sonu. Activating the sheet first did the trick.
Ed "sonu" wrote in message ups.com... or you can use the following two lines Worksheets("Sheet1").activate Worksheets("Sheet1").Range("A1").Select You can not select a range unless that sheet is already activated(selected) Hope this helps. Die_Another_Day wrote: I don't know why but the work around I use is: Application.GoTo Sheets("Sheet1").Range("A1") Charles Ed wrote: I have a Workbook_Open macro as follows: Private Sub Workbook_Open() Worksheets("Sheet2").Visible = True Worksheets("Sheet3").Visible = xlVeryHidden Worksheets("Sheet1").Visible = True Worksheets("Sheet1").Range("A1").Select End Sub The last line fails with " "Select" method of "Range" class failed." I then changed it to Worksheets("Sheet1").Range("A1").Activate and got the same failure error. Why? Ed |
All times are GMT +1. The time now is 11:56 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com