Need Formula for Getting Worksheet Name

shade73

New Member
Joined
Nov 14, 2005
Messages
3
Hey, I'm trying to insert the name of my worksheet into a cell. Does anyone know what formula that would be?

Also, if I wanted to pull from multiple worksheets
(say Sheet1 & Sheet2) and put it in Sheet3.. what is the formula to do that??

Thanks all!
 
Aladin Akyurek said:
=REPLACE(CELL("filename",A1),1,SEARCH("]",CELL("filename",A1)),"")
That's the formula I was trying to find! :p Thanks, Aladin! (Now, shouldn't you be in bed <sup>zzzzz</sup>, it's gotta be like midnight over there...)
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Greg Truby said:
Aladin Akyurek said:
=REPLACE(CELL("filename",A1),1,SEARCH("]",CELL("filename",A1)),"")
That's the formula I was trying to find! :p Thanks, Aladin! (Now, shouldn't you be in bed <sup>zzzzz</sup>, it's gotta be like midnight over there...)

It looks like it's almost midnight. :devilish: My roster says the class I have to give is at 1240 tomorrow. BTW, the REPLACE formula is the shortest native idiom available. If you don't have morefunc, that is.
 
Upvote 0
wow, didn't mean to spark such a debate! lol. At any rate both of those formula's work great.

Thanks!
 
Upvote 0
This is a custom sheet function.

It works both in a sheet or in a sub.

Sheet syntax:

=shName()

which returns the name of the active sheet.

Function shName(Optional CellRef As Range) As String
'Get active sheet name function!

Application.Volatile
On Error GoTo myErr
If CellRef Is Nothing Then
'User did not include a cell Refrence!
shName = Application.Caller.Parent.Name
Else
'Use the cell reference added to the function by the user!
shName = CellRef.Parent.Name
End If
GoTo myEnd

myErr:
MsgBox "You may use this Function, on a" & vbCr & _
"WorkSheet with or without a" & vbCr & _
"Cell Reference Parameter." & vbCr & vbCr & _
"Like: =shName(A1) or =shName()" & vbCr & vbCr & _
"To use this Function in a Sub as code," & vbCr & _
"you must add a Cell Reference as a" & vbCr & _
"Parameter!" & vbCr & vbCr & _
"Like: shName([A1])" & vbCr & _
"Which returns the currently active" & vbCr & _
"Sheet Name."

myEnd:
End Function
 
Upvote 0

Forum statistics

Threads
1,216,520
Messages
6,131,135
Members
449,626
Latest member
Stormythebandit

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