LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Problem referring to a particular sheet in VBA

I need to reference cells in VBA using sheet-level names, which I have
set up using Name Manager. But I ran into some troubles, so I tried to
boil it down to figure it out. I have arrived at the situation below,
and I am baffled as to why this doesn't work:

For i = 1 To Sheets.Count
Debug.Print "Sheet " & i & " is named """ & Sheets(i).Name &
""""
Debug.Print Range("'" & Sheets(i).Name & "'!A1").Address
Next i

I get:
Sheet 1 is named "Current"
$A$1
Sheet 2 is named "Past"
**error here**

Runtime error '1004':
Method 'Range' of object '_Worksheet' failed

I tried it with and without the apostrophes to delimit the sheet name.
I even copied the Current sheet into a new workbook in case there was
some hidden corruption. No luck.

Any ideas? What am I missing?

Thanks
tbone
 
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
Referring to the only sheet Otto Moehrbach Excel Programming 3 April 5th 07 05:11 PM
Formula referring to a different sheet luvthavodka Excel Discussion (Misc queries) 1 November 12th 06 10:05 PM
Referring to a sheet Virginia Excel Programming 2 April 10th 05 02:50 PM
referring to previous sheet Iolao Excel Discussion (Misc queries) 3 November 26th 04 08:40 PM
problem referring to Range and Cells Kevin Excel Programming 8 February 28th 04 01:05 AM


All times are GMT +1. The time now is 05:17 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"