Returing Sheet name in a cell

THETORBY5

New Member
Joined
Aug 22, 2002
Messages
3
What is the formula to return a sheet name into a cell. The cell that would display the sheet name is not in the same sheet.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
sheets("YourOtherSheet").Range("TheRangeOr CellOnThatSheet") = ActiveSheet.Name

For example

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Sheets("MySheet").Range("A1") = ActiveSheet.Name
End Sub

My sheet 1 is renamed MyMan
My Sheet 2 is renamed MySheet

The above puts MyMan in cell A1 of the sheet named MySheet when ever you click anywhere on the sheet named MyMan

Yours in EXCELent Frustration

KniteMare
This message was edited by KniteMare on 2002-08-23 09:01
 
Upvote 0
If the sheet name you need to return is some other sheet than where the formula is located, how are you going to specify what sheet?
 
Upvote 0
On 2002-08-23 08:57, Smiffy wrote:
If the sheet name you need to return is some other sheet than where the formula is located, how are you going to specify what sheet?

Good question...

The following perhaps:

=SHEETNAME(2)

which produces the sheetname as given by the user referring to the internal index that Excel maintains.

The function is part of the morefunc add-in, which is available from:

http://longre.free.fr/english/index.html
 
Upvote 0
Aladin:
That is interesting, and the AddIn reference explains why I could not find it as a formula, thus my prior submitted response as a VBA solution.

Learn something new every day!

Yours in EXCELent Frustration

KniteMare
 
Upvote 0
Thank you for your help, it worked.

How about the reverse. How do I make a sheetname equal a cell name within that sheet. Once that is accomplished how do I correct all my previous VBA code in the workbook referencing; for example a sheet named projections when the cell that determines the sheetname changes from "projections" to "actuals".
 
Upvote 0
THETORBY5
Your code, i am assuming here, references the sheets by name not by sheet number. You need to change these references to variibles

something like this

dim shtName as string
shtName = Sheets(1).Name'or what ever the sheet reference number is

Sheets(shtName)' and what ever you were doing with the sheet name to follow here


To do the reverse:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Sheets(2).Name = "MySheet"
End Sub



Yours in EXCELent Frustration

KniteMare



_________________
Of course I can, and it will take only 900 hours of programming time to do it.
This message was edited by KniteMare on 2002-08-23 12:05
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,159
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top