current sheetname into cell

spilner

Board Regular
Joined
Jun 7, 2011
Messages
146
hi,ive this code from somewhere in this forum.

Code:
Function WhoAmI() As String

Dim wb As Workbook
Dim ws As Worksheet

Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet

Application.Volatile
WhoAmI = ws.Name

Set wb = Nothing
Set ws = Nothing

End Function


use =WhoAmI()

this code is working great but i want the number in 6 digits.

example if the sheetname is 5.then in the cell i want it as 000005.
if 700 then 000700

can someone help?thanks a lot
 
Last edited:

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
its not working.
one thing is if i create a copy of the sheet name.the cell equal to the other cell.not the current cell.

example current sheetname is 60
i create a copy of 60 sheetname.in the cell show not show 60 (2).still show 60 every of the new copy sheets.

thanks for the help tho
 
Upvote 0
i am using excel 2007


A1: 000700

Spreadsheet Formulas
Cell Formula
A1 =TEXT(SHEETNAME(),"000000")
 
Upvote 0
Make sure the file is saved first then

=TEXT(RIGHT(CELL("filename",A1),LEN(CELL("filename",A1))-FIND("]",CELL("filename",A1))),"000000")
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,756
Members
452,940
Latest member
rootytrip

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