Solved

Renaming the Active sheet tab without selecting it first?

Posted on 2016-09-17
7
53 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 20

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 21

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 21
ID: 41804748
you're welcome ~ happy to help
0
 
LVL 20

Expert Comment

by:Roy Cox
ID: 41805089
Pleased to help
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
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…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

622 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