LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Get SheetName from cell

Hi CLR,

You should separate the sheet name from the range, so Info!L1 wont work.

You should use to separate cell for the sheetname Info and cell L1

HTH


"CLR" wrote:

Thanks, but I can't seem to get it to work.......I'm using XL97, maybe thats
why?

When I use this code, the messagebox comes up with the right name, but the
next line won't work........gives "Subscript out of range" error.

Sub sht_select()
Dim mySheet As String
mySheet = Range("info!L1").Value
MsgBox mySheet
Sheets(mySheet).Select
End Sub

Vaya con Dios,
Chuck, CABGx3



"Brotha Lee" wrote:

CLR,

Try the following.

Let's say cell A1 in your sheet contains the sheetname and cell A2 the cell
reference. You can use the following then

sub sht_select()
dim mySheet as string
dim myRange as string

mySheet = activesheet.range("A1").value
myRange = activesheet.range("A2").value

sheets(mySheet).select
activesheet.range(myRange).select

end sub

"CLR" wrote:

Hi All.......
Right now I am using the following line to select a sheet.

Sheets("MySheetName").Select

I would rather like to select the sheet without having to hardcode the name
in the macro, that is, I would like to specify a SheetName and CellAddress
that would have the sheet name entered in it.

Any help would be much appreciated.

Vaya con Dios,
Chuck, CABGx3


 
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
Use cell contents to refer to a sheetname in a formula cp Excel Worksheet Functions 6 September 29th 08 06:56 PM
Automatically update SheetName in workbook sub if SheetName changes [email protected] Excel Discussion (Misc queries) 3 February 29th 08 04:33 PM
Accessing the sheetname in a cell Kanagabalan Excel Worksheet Functions 4 February 28th 06 10:56 AM
can formula to read sheetname from a cell? Todd Excel Worksheet Functions 2 December 8th 04 06:21 PM
Sheetname = Cell content ........ is it possible? SpeeD[_2_] Excel Programming 2 July 31st 03 02:43 AM


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