Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default sheet reference

I want to do the following:

(say) I have an excel file by name XYZ.xls and this file has many
worksheets in it. But I am interested in a specific sheet with name
"XYZ all". How to reference the sheet when the filename XYZ could be
different every time I run the macro ? Please help. Thanks

Srikanth
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default sheet reference

Dim bk as Workbook, bk1 as Workbook
Dim sh as Worksheet
set bk1 = Nothing
for each bk in Application.Workbooks
set sh = Nothing
On error resume next
set sh = bk.worksheets("XYX all")
On Error goto 0
if not sh is nothing then
set bk1 = bk
exit for
End if
Next

if not bk1 is nothing then
msgbox "XYX all found in " & bk1.name
End if

--
Regards,
Tom Ogilvy

"Srikanth" wrote in message
m...
I want to do the following:

(say) I have an excel file by name XYZ.xls and this file has many
worksheets in it. But I am interested in a specific sheet with name
"XYZ all". How to reference the sheet when the filename XYZ could be
different every time I run the macro ? Please help. Thanks

Srikanth



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default sheet reference

I read your question that you want to reference a sheet name that consists
of the following:
The file name without the ".xls" followed by:
A space, followed by:
"all"

Is that what you want?
If so, then something like this might help.
Dim ShtName As String
ShtName=Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name)-4)
ShtName = ShtName & " all"

Or maybe I didn't read your question right.
HTH Otto

"Srikanth" wrote in message
m...
I want to do the following:

(say) I have an excel file by name XYZ.xls and this file has many
worksheets in it. But I am interested in a specific sheet with name
"XYZ all". How to reference the sheet when the filename XYZ could be
different every time I run the macro ? Please help. Thanks

Srikanth



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
Nesting a sheet name reference within a cell reference??? Broyston Excel Discussion (Misc queries) 9 July 8th 08 08:35 PM
How To make a sheet reference Variable (eq: sum(sheet!D2:H2)) John Linker Excel Discussion (Misc queries) 3 June 16th 08 11:29 PM
multiple cell reference from sheet to sheet KMR R.A. Excel Worksheet Functions 0 May 29th 08 12:48 AM
Changing sheet reference to cell reference TeeJay Excel Worksheet Functions 3 October 19th 07 11:50 AM
Relative Sheet Reference (Summary Sheet) [email protected] Excel Discussion (Misc queries) 2 October 1st 05 10:42 AM


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