Solved

Renaming the Active sheet tab without selecting it first?

Posted on 2016-09-17
7
45 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
7 Comments
 
LVL 5

Accepted Solution

by:
D Patel earned 251 total points
Comment Utility
Private Sub updateWorksheetName_Click()

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

Assisted Solution

by:Roy_Cox
Roy_Cox earned 83 total points
Comment Utility
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 28

Assisted Solution

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

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

Open in new window

0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 18

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 83 total points
Comment Utility
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
Comment Utility
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 18
Comment Utility
you're welcome ~ happy to help
0
 
LVL 17

Expert Comment

by:Roy_Cox
Comment Utility
Pleased to help
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
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…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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…

771 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

8 Experts available now in Live!

Get 1:1 Help Now