Worksheet Names

helpexcel

Well-known Member
Joined
Oct 21, 2009
Messages
656
Hi - I've been reading a bunch of posts on this and haven't found any that work for me. I have a workbook with a number of sheets. What i would like to happen is what ever value is put in A5 on sheet one will be used to create the worksheet names. So if A5="Red" the worksheets will be named "Red Balloons" "Red Cars" "Red Food". I plan an expanding this code for values in A10 and A20. I'm assuming the code would have to go into each worksheet individually, with a private sub?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Thanks for asking this, I have wanted to do it myself.

A single line in a worksheet activate sub is working for me.

Code:
Private Sub Worksheet_Activate()
ActiveSheet.Name=Range("A5").Value
End Sub

I think I remember any event called something like "AnySheetOnActivate" which might be able to do this from the workbook module, could be even better.
 
Upvote 0
.
This is one method :

Code:
Option Explicit


Private Sub Worksheet_Activate()
    Me.Name = Range("A5").Value
End Sub

Paste above macro into the sheet module.
 
Upvote 0
the ActiveSheet doesn't work, because the sheets that are changing names aren't the active sheet. Sheet1 is the ActiveSheet. I tried editing the code for the sheet module, but it didn't work.

Option Explicit
Private Sub Worksheet_Activate()


Dim ws1, LName As Worksheet


Set ws1 = ThisWorkbook.Sheets("Sheet1")
LName = ws1.Range("A5") & " " & "Balloon"


Me.Name = LName
End Sub
 
Upvote 0
.
Code:
Option Explicit


Private Sub Worksheet_Activate()
    Me.Name = Range("A5").Value & " Balloon"
End Sub
 
Upvote 0
Perfect, thanks!

How do i get that to run when the value in A5 is changed? A5 is on a different sheet than the ones being named.
 
Upvote 0
.
Let's say you want to target cell F23 on Sheet3 :

Code:
Option Explicit


Private Sub Worksheet_Activate()
    Me.Name = Range("F235").Value & " Balloon"
End Sub

Place that macro in the Sheet module for Sheet 3.
 
Upvote 0
works great, but i have to click on the sheet for the code to kick in. is there a way to make it happen with having to click on the sheet?
 
Upvote 0
Will you be entering the data into the cell manually then hitting ENTER ?

Or is the cell value changing by a formula in the cell ?

Tell ya what, try this :

Code:
Option Explicit


Private Sub Worksheet_SelectionChange(ByVal Target As Range)


    Me.Name = Range("F23").Value & " Balloon"


End Sub
 
Last edited:
Upvote 0
It will be changed with a formula. So the value will be changed on Sheet1, which will update a cell on all the other sheets.
 
Upvote 0

Forum statistics

Threads
1,215,470
Messages
6,124,993
Members
449,201
Latest member
Lunzwe73

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