Macro To Changes Tab Names Based on Cell Value

legalhustler

Well-known Member
Joined
Jun 5, 2014
Messages
1,091
I need help with a macro that will change all the tab names of my worksheets based on the left 4 characters (they are generally numbers and has a leading zero) from the value in cell A4. If there is no value in cell A4 then the code should do nothing. Can someone help?
 
Last edited:

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,455
Office Version
  1. 365
Platform
  1. Windows
How about
Code:
Sub legalhustler()
   Dim Ws As Worksheet
   
   For Each Ws In Worksheets
      If Not Ws.Range("A4") = "" Then Ws.Name = Left(Ws.Range("A4"), 4)
   Next Ws
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,109,204
Messages
5,527,401
Members
409,760
Latest member
zeeshansyed

This Week's Hot Topics

Top