Solved

Renaming the Active sheet tab without selecting it first?

Posted on 2016-09-17
7
52 Views
Last Modified: 2016-09-19
When I used the vba recorder I got the following:
Sheets("ImportedSODateTemplateA").Select
    Sheets("ImportedSODateTemplateA").Name = "ImportedSODateTemplate"

Open in new window


How can I just rename this without having to select the sheet tab first.  I just want to rename whatever the active sheet tab is.
0
Comment
Question by:RWayneH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Accepted Solution

by:
D Patel earned 251 total points
ID: 41802975
Private Sub updateWorksheetName_Click()

   ActiveSheet.Name = "Flight " & ActiveSheet.Range("FlightNumber") & " - Check Number " & ActiveSheet.Range("PerformancCheckNumber")
   worksheetName.Caption = ActiveSheet.Name
   
End Sub
0
 
LVL 19

Assisted Solution

by:Roy_Cox
Roy_Cox earned 83 total points
ID: 41802983
Do you mean, which tidies up the recorded code

Sheets("ImportedSODateTemplateA").Name = "ImportedSODateTemplate"

Open in new window


Is this asked elsewhere because I can't see where Dhara can have come up with his answer?
0
 
LVL 31

Assisted Solution

by:Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj) earned 83 total points
ID: 41802985
Only this line will do the trick.....

Sheets("ImportedSODateTemplateA").Name = "ImportedSODateTemplate"

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 83 total points
ID: 41803275
the macro recorder records what you do -- which is to select something and then change it.  Rarely does an object have to actually be selected -- exceptions to this are freezing panes, resizing windows, and a few others.
0
 

Author Comment

by:RWayneH
ID: 41804634
Dhara, reply gave me the clue I needed.  Because I am importing a sheet into a workbook and users can at times rename there sheets, the macro I run to harvest some of the data needs a specific sheet name.  Thanks all for the help.

Solution was:
ActiveSheet.Name = "ImportedSODateTemplate"
0
 
LVL 20
ID: 41804748
you're welcome ~ happy to help
0
 
LVL 19

Expert Comment

by:Roy_Cox
ID: 41805089
Pleased to help
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

752 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