Put Active Worksheet's Name in a Cell

C

coreymartin

Is there a way to put the active worksheet's name in the cell? Not the
file name of the whole workbook, just the name of the currently
selected sheet.

Thanks for your help.
 
R

Rob

Hi Corey,

There are a few ways this can be done using either macros or functions,
here's one of each:

*=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,
LEN(CELL("filename",A1))-FIND("]",CELL("filename",A1)))
(sourced from Chip Pearson's site, http://www.cpearson.com/excel/excelF.htm)
I recommend checking this page out as it also shows other possibilities.

*Sub InsertSheetNames()
Application.ScreenUpdating = False
Dim S As Worksheet
For Each S In ActiveWorkbook.Worksheets
S.Range("a1").Value = S.Name
Next S
Application.ScreenUpdating = True
End Sub
(sourced from ?, this can be inserted in a module & run as required to put
the respective sheet name in cell A1 of every sheet or adapted & put in the
"this workbook" section to run when the file is opened.)

Hth

Rob Brockett
NZ
 
Top