View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default Subscript out of range when selecting worksheet...

Do you have a sheet named 'Sheet1' or a sheet named 'Sheet8'? The code is
looking for an object that doesn't exist.

Something like this:
Workbooks("Book1.xls").Sheets("Sheet1").Range("A1" )
But you don't need the Workbooks("Book1.xls") part if you are just
referencing sheets in the active Workbook.

HTH,
Ryan---
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"jfcby" wrote:

Hi,

Why does the script below give me the "subscript out of rage error"
when tring to select a worksheet?

Sub ActvateWorksheet()
'Activate worksheet
Worksheets("Sheet8").Activate
End Sub

In the help file I found:

"The following example uses the Activate method to activate Sheet1"
Sub ActvateWorksheet()
Worksheets("Sheet1").Activate
End Sub

But, when I run the macro it gives me the above error.

Thank you for your help,
jfcby