Tab name from list

jammoca

Banned
Joined
Nov 6, 2002
Messages
1,100
is there a code that automatically names a Tab on the content of a cell

example, if cell A1 says " Team Aloisi" the tab would be named Team Aloisi
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Not sure about that but I do know if you type the code
=RIGHT(CELL("filename",A1),LEN(CELL("filename",A1))-FIND("]",CELL("filename",A1))) into A1, it will say the Tab name as the text in A1. Thats the best I can do for you.

Hope that helps.
 
Upvote 0
Depends on how you want to do it, but this may be a start:

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_SheetActivate(<SPAN style="color:#00007F">ByVal</SPAN> Sh <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>)
    <SPAN style="color:#00007F">Dim</SPAN> rng <SPAN style="color:#00007F">As</SPAN> Range
    
    <SPAN style="color:#00007F">With</SPAN> ActiveSheet
        <SPAN style="color:#00007F">Set</SPAN> rng = Range("A1")
        <SPAN style="color:#00007F">If</SPAN> rng = "" <SPAN style="color:#00007F">Then</SPAN>
            <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
        Else: .Name = rng
        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
    
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

Note there's no error handling for invalid names or if the sheet name already exists, only if A1 is blank.

HTH,

Smitty
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
ActiveSheet.Name = Range("A1")
End Sub
 
Upvote 0
Thanks Hotpepper, but I must be doing something terribly wrong. I copy that code ( it's honestly the 40th or more that I've tried so far ) into a module for that sheet and click out of the module but the sheet still isn't renamed. Was I supposed to do something extra ??
 
Upvote 0
Mine uses the Change event so that when you change the value in A1, it changes the name of the sheet. If you want to keep the existing value in A1, go into cell A1, hit the F2 key and then Enter. Then everytime you change this cell after that it will change the name of the sheet, assuming it is a valid sheet name.
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,666
Members
448,977
Latest member
moonlight6

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