View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Subscript out of range when selecting worksheet...

Make sure your worksheet names do not have any spaces in them. Here is an
easy way to see... run this code line in the Immediate window

For Each S In Worksheets:? "<" & S.Name & "":Next

It will list out each worksheet name with angle brackets around them... the
angle brackets should butt up against the worksheet name... if it doesn't,
then you have one or more spaces in the worksheet name... rename these
sheets to what they should be and then run you code again.

--
Rick (MVP - Excel)


"jfcby" wrote in message
...
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