• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 56
  • Last Modified:

Renaming the Active sheet tab without selecting it first?

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
RWayneH
Asked:
RWayneH
4 Solutions
 
D PatelD Patel, Software EngineerCommented:
Private Sub updateWorksheetName_Click()

   ActiveSheet.Name = "Flight " & ActiveSheet.Range("FlightNumber") & " - Check Number " & ActiveSheet.Range("PerformancCheckNumber")
   worksheetName.Caption = ActiveSheet.Name
   
End Sub
0
 
Roy CoxGroup Finance ManagerCommented:
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
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Only this line will do the trick.....

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

Open in new window

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
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
 
RWayneHAuthor Commented:
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
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
you're welcome ~ happy to help
0
 
Roy CoxGroup Finance ManagerCommented:
Pleased to help
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now