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

The error basically means that the active
workbook doesn;t have a worksheet called
"Sheet 8". The mostly like explanation I
can think of is that a different workbook is active,
which does not have a Sheet8. If that's the case,
you need to activate the correct workbook first:

Workbooks("MyWorkbook.xls").Activate
Worksheets("Sheet8").Activate

Andrew


On 3 Aug, 16:05, 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