+ Reply to Thread
Results 1 to 4 of 4

Create new worksheets with names

  1. #1
    Registered User
    Join Date
    12-04-2008
    Location
    chicago
    Posts
    11

    Create new worksheets with names

    I have a worksheet that has a list of stock names (tickers) and a template worksheet with a bunch of calculations. What I want to do is create a new template worksheet for each of the stock names that I have. So If I have 50 stock names I would create 50 new template sheets with the stock name as the name of the stock as the worksheet name.

    Stocks (in worksheet("Stocks"))
    aapl
    msft
    IBM

    Would generate 3 new worksheets named "aapl", "msft", "IBM" each based on the template worksheet
    Last edited by asavage; 12-14-2008 at 05:51 PM. Reason: clarification

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,663
    try this macro:
    It assumes the list of names is in column a since you did not specify.
    It assumes a template sheet name of "mastertemplate" since you did not specify.
    It looks at all of column A on the "stocks" sheet for names since you did not specify a cell range.


    Please Login or Register  to view this content.
    --------------------------
    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Make any custom changes to the macro if needed at this time
    8. Save the Macro by pressing the keys CTRL+S
    9. Press the keys ALT+Q to exit the Editor, and return to Excel.

    To Run the Macro...
    To run the macro from Excel, open the workbook, and press ALT+F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    12-04-2008
    Location
    chicago
    Posts
    11
    Proton, you made all of the correct assumptions (sorry that my instructions weren't precise still in the newbie stage). But I do have a question for you. It worked the first time perfectly. But the second time I ran it it gave me an error because the worksheets were already created. Is there a way to delete all worksheets except "stocks" and "Mastertemplate" before the for loop statement?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Minor tweak:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1