Solved

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

Posted on 2011-02-28
3
1,227 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
nested excel formula 5 29
using vb script 5 47
Excel Named Range 31 44
Excel VLookup in a macro where returned column changes every month 7 11
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 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