Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1390
  • Last Modified:

Excel VBA - add new sheet after sheet 1 and name it

Hi

What VBA code would I use to add a new Excel sheet directly after sheet 1 and then name that sheet "Data"
Thanks
0
Murray Brown
Asked:
Murray Brown
2 Solutions
 
SiddharthRoutCommented:
Try this

Sub Sample()
    Dim NewSht1 As Worksheet
    Sheets.Add after:=Sheet1
    Set NewSht1 = ActiveSheet
    NewSht1.Name = "Data"
End Sub

Open in new window


Sid
0
 
StephenJRCommented:
Perhaps this?

Sheets.Add(After:=Sheets(1)).Name = "Data"
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thank you both
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

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