?
Solved

Excel New a worksheet in a macro

Posted on 2014-08-12
3
Medium Priority
?
458 Views
Last Modified: 2015-12-05
Hello Experts Exchange
I have a Excel 2010 spreadsheet that I want a macro to create a new worksheet and give it a name of import.

I have recorded a macro and have the following code;
Sheets.Add After:=Sheets(Sheets.Count)
    'Sheets("Sheet1").Select
    'Sheets("Sheet1").Name = "Import"

Open in new window


However I am running the macro on many different Excel files, and Sheet1 maybe not be the new worksheet name in some files.

Can you provide the code I would need to create a new worksheet and rename it to import, please?

Regards

SQLSearcher

Regards
0
Comment
Question by:SQLSearcher
3 Comments
 
LVL 54

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 40255523
Hi,

pls try

Set NewSheet = Sheets.Add(After:=Sheets(Sheets.Count))
NewSheet.Name = "Import"

Regards
0
 

Author Closing Comment

by:SQLSearcher
ID: 40255610
Thank you very much for your help.
0
 

Expert Comment

by:Bright01
ID: 41357500
Rgonzo,

Quick question.... if you fire this Macro multiple of times, will it use the same name followed by the copy number for each new worksheet?

B.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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.

831 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