Code to get worksheet name into a cell

Hydestone

Board Regular
Joined
Mar 29, 2010
Messages
137
Is it possible to have the worksheet name autopopulate into a cell?

Example - I want the sheet name to appear in cell F1. Is that possible? Also, if I rename Sheet 1 to 12345, the info in cell F1 would change from Sheet 1 to 12345.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Put this formula in F1:

Code:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
 
Upvote 0
For some reason, when I copy the worksheet which is using the reference above, the new worksheet displays #VALUE in the cell, instead of the sheet name. If I save the file, it still says #VALUE . If I save, close, and reopen - the formula then works and the cell shows the worksheet name. Any way to get the sheet name to show without closing and reopening the workbook?
 
Upvote 0
Do you have calculations set to manual or Automatic?
 
Upvote 0
Are you copying the sheet to a brand new workbook?
 
Upvote 0
Fluff hit the nail on the head, of course. The CELL("filename", A1) finds the full path...but if you haven't saved the workbook, there is no path. If you save it, does the sheet name update correctly?
 
Upvote 0
Yes, copying to new workbook. When I click save, nothing changes. When I close the book and then reopen, the information populates in the cell.

Any way to make it populate without closing and reopening?
 
Upvote 0
After saving press F9, does that make a difference?
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,915
Members
448,532
Latest member
9Kimo3

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