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

I have one Workbook that has a unique problem. When I attempt to access it from code in a module with the name of the sheet or "Sheet1", I get a <subscript out of range error. I can access when I use the number (provided it is the first sheet). All the other worksheets in the workbook can be accessed by name

The code is

With Worksheets("Sheet1") ' return <subscript out of range erro

With Worksheets(1) ' work

NOTE: This same worksheet will not run a function attached to that sheet or from a module

Is there some switch that needs to be changed
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Recognizating worksheet name

John,

Maybe stating the obvious, but worksheet 1 hasn't been renamed by any
chance?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John H" wrote in message
...
I have one Workbook that has a unique problem. When I attempt to access

it from code in a module with the name of the sheet or "Sheet1", I get a
<subscript out of range error. I can access when I use the number
(provided it is the first sheet). All the other worksheets in the workbook
can be accessed by name.

The code is:

With Worksheets("Sheet1") ' return <subscript out of range error

With Worksheets(1) ' works

NOTE: This same worksheet will not run a function attached to that sheet

or from a module.

Is there some switch that needs to be changed



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Recognizating worksheet name

The sheet has been named the same for at least five years. I have not tried changing its name since it is used in over 500 formulas using Excel functions. The name works in Excel functions, just not in VBA functions, while other worksheet names work in both. Also, the worksheet is NOT hidden

John H
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Recognizating worksheet name

John,

It might be a long shot, but try using

With ThisWorkbook.Worksheets("Sheet1")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"John H" wrote in message
...
The sheet has been named the same for at least five years. I

have not tried changing its name since it is used in over 500
formulas using Excel functions. The name works in Excel
functions, just not in VBA functions, while other worksheet names
work in both. Also, the worksheet is NOT hidden.

John H



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Recognizating worksheet name

Using 'With ThisWorkbook.Worksheets("Sheet1")' nor its actual sheet name in place of "Sheet1" worked

Thanks anyway
John H
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
automatically appending newly added data on worksheet to a master list worksheet tabylee via OfficeKB.com Links and Linking in Excel 0 December 17th 09 04:24 PM
plot graph from multiple worksheet as embedded chart object on every worksheet [email protected] Charts and Charting in Excel 3 August 24th 06 07:26 PM
plot graph from multiple worksheet as embedded chart object on every worksheet jeftiong New Users to Excel 0 August 23rd 06 01:50 PM
Upload multiple text files into 1 excel worksheet + put the filename as the first column in the worksheet Aster Excel Worksheet Functions 3 March 12th 06 09:58 AM
Attaching a JET database to an Excel Worksheet OR storing large binary data in a worksheet Ant Waters Excel Programming 1 September 3rd 03 11:34 AM


All times are GMT +1. The time now is 12:01 PM.

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"