Solved

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

Posted on 2011-02-28
3
1,163 Views
Last Modified: 2012-08-13
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
Comment
Question by:murbro
3 Comments
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 300 total points
ID: 34996324
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
 
LVL 24

Assisted Solution

by:StephenJR
StephenJR earned 200 total points
ID: 34996328
Perhaps this?

Sheets.Add(After:=Sheets(1)).Name = "Data"
0
 

Author Closing Comment

by:murbro
ID: 34996406
Thank you both
0

Featured Post

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.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

705 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

21 Experts available now in Live!

Get 1:1 Help Now