Solved

Renaming the Active sheet tab without selecting it first?

Posted on 2016-09-17
7
49 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 6

Accepted Solution

by:
DPatel 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 18

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 29

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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 19

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

Expert Comment

by:Roy_Cox
ID: 41805089
Pleased to help
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
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.

777 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