Changing name of sheet using VBA

seh27

New Member
Joined
Mar 22, 2013
Messages
17
I have a workbook with multiple sheets. Each sheet has a title (just words in a cell). Is there VBA formula that will have the sheet take the name of the title and also chnage when the title name changes? Thanks
 
OK, so A1 changes via a formula.

We need to use the Calculate event instead of Change..
Try
Code:
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Sh.Name = Sh.Range("A1").Value
End Sub
Same instructions as before to install the code to the ThisWorkbook module.
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I think I just don't know how to use this. :( I opened up macros, clicked this workbook, clicked create, deleted the sub and end sub that is automatically created, copied and pasted exactly what you sent me, and then exited out of the macros. Then I changed the cell it to see if it worked and nothing. Thank you for putting up with me...
 
Upvote 0
ok, when you click "ThisWorkbook"
Look at the title bar of the VBA window, it should say something like
"Micorosft Visual Basic for Applications - bookname.xls - [ThisWorkbook (Code)]

Does that say ThisWorkbook, or does it say some sheetname ?

Make sure to "Double Click" on ThisWorkbook, and check that the titlebar says ThisWorkbook
 
Upvote 0
ok, when you click "ThisWorkbook"
Look at the title bar of the VBA window, it should say something like
"Micorosft Visual Basic for Applications - bookname.xls - [ThisWorkbook (Code)]

Does that say ThisWorkbook, or does it say some sheetname ?

Make sure to "Double Click" on ThisWorkbook, and check that the titlebar says ThisWorkbook

I did double click ThisWorkbook before hitting create but the title bar says
bookname.xsl - Module1 (Code)
 
Upvote 0
I don't follow what this means "before hitting create" ?

From the beginning...

open your excel workbook.
Right click on a Sheet's Tab and select "View Code" - this opens the VBA Window
Click View - Project Explorer
In the top left area you should see some project objects like sheets and modules
Find the object labled ThisWorkBook and double click on it
Or even better, Right Click on ThisWorkBook and select View Code
Now your title bar should say something like bookname.xsl - ThisWorkBook (Code)

Paste the code there
 
Upvote 0

Forum statistics

Threads
1,216,089
Messages
6,128,760
Members
449,466
Latest member
Peter Juhnke

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