Excel New a worksheet in a macro

Posted on 2014-08-12
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").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?



Question by:SQLSearcher
    LVL 47

    Accepted Solution


    pls try

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


    Author Closing Comment

    Thank you very much for your help.

    Expert Comment


    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?


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
    This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

    758 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

    13 Experts available now in Live!

    Get 1:1 Help Now