Solved

Auto Changing a Sheet Name based on cell value

Posted on 2016-10-03
9
45 Views
Last Modified: 2016-10-25
Hello,
I currently have a workbook that I am trying to have the tab name reflect what is in the sheets cell "A1" for every sheet.  I currently have the code set up as below, however it requires that I click each tab in order to get it to change, is there a way to get it to do this function without having to click the sheet tab?

Private Sub Worksheet_Activate()
On Error Resume Next
Me.Name = Range("a1").Value
End Sub
0
Comment
Question by:christina Ridings
  • 3
  • 2
9 Comments
 
LVL 28

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41827043
You may have this sub-routine on a Standard Module and run this to rename all the sheets.

Sub ChangeSheetNames()
Dim ws As Worksheet
On Error Resume Next
For Each ws In Worksheets
   If ws.Range("A1").Value <> "" Then
      ws.Name = ws.Range("A1").Value
   End If
Next ws
End Sub

Open in new window

0
 
LVL 45

Accepted Solution

by:
aikimark earned 250 total points (awarded by participants)
ID: 41827051
Can put code into the Workbook_Open() event that will iterate through the worksheets.
0
 
LVL 8

Assisted Solution

by:Koen
Koen earned 250 total points (awarded by participants)
ID: 41827135
Also maybe test your A1 value for illegal characters and length
(21 characters max, symbols not allowed are  \ ? / : [ ] *)
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 28

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41827424
@Koen
On Error Resume Next would take care of all those issues.
Also the max characters allowed are 31 not 21.
0
 
LVL 8

Expert Comment

by:Koen
ID: 41827596
I just use a function for files and sheets that removes the illegale characters...skipping it usually is not what the customer wants.
0
 
LVL 28

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41858241
As per the objection raised in Post ID: 41848750.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now