[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Auto Changing a Sheet Name based on cell value

Posted on 2016-10-03
9
Medium Priority
?
124 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
6 Comments
 
LVL 33

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 46

Accepted Solution

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

Assisted Solution

by:Koen
Koen earned 1000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 33

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 9

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 33

Expert Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

834 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