Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Subscript out of range when selecting worksheet...

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Subscript out of range when selecting worksheet...

Andrew,

Only 1 workbook is open. It has a Sheet8. And this macro does not work
either:

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

Thank you for your help,
Frankie
  #5   Report Post  
Posted to microsoft.public.excel.programming
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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Subscript out of range when selecting worksheet...

Hi,

Thanks everyone for your help.

I created a new workbook and the macro below works great. Now I'm
going to troubleshoot my existing workbook and find out why it will
not activate the worksheets.

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


Thanks,
jfcby
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subscript out of range error - selecting a sheet John[_140_] Excel Programming 3 August 3rd 09 12:35 AM
I Get subscript out of range when tying to access worksheet Pam[_7_] Excel Programming 2 February 26th 07 06:55 PM
selecting cell range in other worksheet without switching to worksheet suzetter[_4_] Excel Programming 4 June 22nd 05 08:55 PM
Subscript out of range when adding worksheet RB Smissaert Excel Programming 6 January 7th 04 03:11 PM
Subscript our of range when activating a worksheet J.E. McGimpsey Excel Programming 0 October 7th 03 07:12 PM


All times are GMT +1. The time now is 05:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"