Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default activating correct worksheet

Hi

The code Worksheets(Names).Activate or Select brings up error 9 Subscript
out of range if sitting in the Names Worksheet, but will activate if
sitting in any other sheet, why?
What am I missing?
I just want to be sure the Formatting sub procedure called up runs on the
correct sheet.

TIA

--
Thank you

Regards
Aussie Bob C.
Using Windows XP Home + Office 2003 Pro
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default activating correct worksheet

? activesheet.Name
Sheet2
Worksheets("Sheet2").Activate

in the immediate window did not raise any error. What you say is very
strange.

--
Regards,
Tom Ogilvy

"Robert Christie" wrote in message
...
Hi

The code Worksheets("Names").Activate or Select brings up "error 9

Subscript
out of range" if sitting in the "Names" Worksheet, but will activate if
sitting in any other sheet, why?
What am I missing?
I just want to be sure the Formatting sub procedure called up runs on the
correct sheet.

TIA

--
Thank you

Regards
Aussie Bob C.
Using Windows XP Home + Office 2003 Pro



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default activating correct worksheet

Hi Robert,

Your code works fine for me also. If I define a range as "Names" I get a
"Type mismatch" message. Thereafter, surprisingly, the defined name seems
fine and your code still works. But do you have such a name?

Regards,
Peter T

"Robert Christie" wrote in message
...
Hi

The code Worksheets("Names").Activate or Select brings up "error 9

Subscript
out of range" if sitting in the "Names" Worksheet, but will activate if
sitting in any other sheet, why?
What am I missing?
I just want to be sure the Formatting sub procedure called up runs on the
correct sheet.

TIA

--
Thank you

Regards
Aussie Bob C.
Using Windows XP Home + Office 2003 Pro



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default activating correct worksheet

Hi Peter

No ranges defined as "Names" in workbook.
Thanks for the post

Regards Bob C.

"Peter T" wrote:

Hi Robert,

Your code works fine for me also. If I define a range as "Names" I get a
"Type mismatch" message. Thereafter, surprisingly, the defined name seems
fine and your code still works. But do you have such a name?

Regards,
Peter T

"Robert Christie" wrote in message
...
Hi

The code Worksheets("Names").Activate or Select brings up "error 9

Subscript
out of range" if sitting in the "Names" Worksheet, but will activate if
sitting in any other sheet, why?
What am I missing?
I just want to be sure the Formatting sub procedure called up runs on the
correct sheet.

TIA

--
Thank you

Regards
Aussie Bob C.
Using Windows XP Home + Office 2003 Pro




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default activating correct worksheet

Hi Tom & Peter

Just replaced the Line "Worksheets("Names").Activate" with
"Sheets("Names").Select" and it selects "Names" wether Names worksheet is
ActiveSheet or not.
Strange very strange.

Thank you both for your posts.

Regards Aussie Bob C.

"Tom Ogilvy" wrote:

? activesheet.Name
Sheet2
Worksheets("Sheet2").Activate

in the immediate window did not raise any error. What you say is very
strange.

--
Regards,
Tom Ogilvy

"Robert Christie" wrote in message
...
Hi

The code Worksheets("Names").Activate or Select brings up "error 9

Subscript
out of range" if sitting in the "Names" Worksheet, but will activate if
sitting in any other sheet, why?
What am I missing?
I just want to be sure the Formatting sub procedure called up runs on the
correct sheet.

TIA

--
Thank you

Regards
Aussie Bob C.
Using Windows XP Home + Office 2003 Pro






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default activating correct worksheet

Found I could duplicate your original problem if trying to activate a Macro
sheet, ie one created with Ctrl-F11.

Sub Test()
Sheets.Add Type:=xlExcel4MacroSheet
For Each sh In ActiveWorkbook.Sheets
Debug.Print TypeName(sh), sh.Type, sh.Name
If sh.Type = xlExcel4MacroSheet Then s = sh.Name
Next
Worksheets(s).Activate 'fails
Sheets(s).Activate
End Sub

Regards,
Peter


"Robert Christie" wrote in message
...
Hi Peter

No ranges defined as "Names" in workbook.
Thanks for the post

Regards Bob C.

"Peter T" wrote:

Hi Robert,

Your code works fine for me also. If I define a range as "Names" I get a
"Type mismatch" message. Thereafter, surprisingly, the defined name

seems
fine and your code still works. But do you have such a name?

Regards,
Peter T

"Robert Christie" wrote in message
...
Hi

The code Worksheets("Names").Activate or Select brings up "error 9

Subscript
out of range" if sitting in the "Names" Worksheet, but will activate

if
sitting in any other sheet, why?
What am I missing?
I just want to be sure the Formatting sub procedure called up runs on

the
correct sheet.

TIA

--
Thank you

Regards
Aussie Bob C.
Using Windows XP Home + Office 2003 Pro






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default activating correct worksheet

Found I could duplicate your original problem if trying to activate a Macro
sheet, ie one created with Ctrl-F11.

Sub Test()
Sheets.Add Type:=xlExcel4MacroSheet
For Each sh In ActiveWorkbook.Sheets
Debug.Print TypeName(sh), sh.Type, sh.Name
If sh.Type = xlExcel4MacroSheet Then s = sh.Name
Next
Worksheets(s).Activate 'fails
Sheets(s).Activate
End Sub

Regards,
Peter


"Robert Christie" wrote in message
...
Hi Peter

No ranges defined as "Names" in workbook.
Thanks for the post

Regards Bob C.

"Peter T" wrote:

Hi Robert,

Your code works fine for me also. If I define a range as "Names" I get a
"Type mismatch" message. Thereafter, surprisingly, the defined name

seems
fine and your code still works. But do you have such a name?

Regards,
Peter T

"Robert Christie" wrote in message
...
Hi

The code Worksheets("Names").Activate or Select brings up "error 9

Subscript
out of range" if sitting in the "Names" Worksheet, but will activate

if
sitting in any other sheet, why?
What am I missing?
I just want to be sure the Formatting sub procedure called up runs on

the
correct sheet.

TIA

--
Thank you

Regards
Aussie Bob C.
Using Windows XP Home + Office 2003 Pro






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
Finding Worksheet and Activating it Rob Excel Discussion (Misc queries) 2 January 30th 07 08:14 PM
Activating a Worksheet? Kenny R Excel Discussion (Misc queries) 3 December 8th 06 05:15 PM
Worksheet activating JamesM[_2_] Excel Programming 0 September 28th 04 04:34 PM
Worksheet activating JamesM Excel Programming 0 September 28th 04 03:55 PM
Activating a worksheet DJH Excel Programming 2 August 10th 04 04:20 PM


All times are GMT +1. The time now is 08:19 PM.

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

About Us

"It's about Microsoft Excel"