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
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

drc2265

Board Regular
Joined
Jul 30, 2007
Messages
96
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.
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
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
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
ActiveSheet.Name = Range("A1")
End Sub
 

jammoca

Banned
Joined
Nov 6, 2002
Messages
1,100
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 ??
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,600
Messages
5,597,114
Members
414,125
Latest member
iQQ

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
Top