+ Reply to Thread
Results 1 to 11 of 11

Macro to create new sheets with numbers in sequence

  1. #1
    Registered User
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    15

    Exclamation Macro to create new sheets with numbers in sequence

    Hi to all,

    I would like to apologize in advance if this has been posted already, I searched the topics to try find it but could not.

    I currently have a spreadsheet with over 600 sheets all numbered sequentially and grows every month. On each sheet there are many details and formulas but most important for this issue is a cell (lets say it's A1 for the course of this thread) that has the same value as the sheet name. So if the sheet is named "523" then cell A1 should read "523".
    Then I have a "Main" sheet that pulls values from the sheets based on the sheet number and dates.

    Up until now I have been creating these sheets manually, however this month I have to add over 400 sheets to this spreadsheet and I simply do not have the time to do it manually.

    Is there a macro that can be programmed to create a copy of the last sheet and name it as 1 more than the last sheet (if the last sheet is names "620" then the macro creates a copy of the sheet and names it "621") and then make the cell A1 on that sheet named as the sheet's name?

    Otherwise I am not going to be able to cut it this month and will be mightily unpopular...

    Thank you all in advance!
    sheets.PNG
    Last edited by canyflyer; 08-21-2013 at 02:49 AM.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro to create new sheets with numbers in sequence

    Hi canyflyer,
    may be something like this (it is assumed that there is already the last sheet with digital name)
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Macro to create new sheets with numbers in sequence

    Hi canyflyer,

    Welcome to the forum!!

    Here's my attempt:

    Please Login or Register  to view this content.
    I would really question your layout though as Excel will sooner or later start having issues with this many tabs (if it doesn't already). Do you really need separate tabs or could you perhaps create a template that's populated by different rows from a master dataset (tab) say?

    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  4. #4
    Registered User
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Macro to create new sheets with numbers in sequence

    Hi Nilem,

    Thanks so much for your fast reply!

    That works well!

    Is there a way of doing the same thing but instead of creating a blank sheet - copying the last one so that all the formulas are included as well and then renaming the sheet and cell A1 accordingly?

    Thanks :-)

  5. #5
    Registered User
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Macro to create new sheets with numbers in sequence

    Quote Originally Posted by Trebor76 View Post

    I would really question your layout though as Excel will sooner or later start having issues with this many tabs (if it doesn't already). Do you really need separate tabs or could you perhaps create a template that's populated by different rows from a master dataset (tab) say?

    HTH

    Robert
    Sorry, not Excel savy enough to know what "a template that's populated by different rows from a master dataset (tab)" is... :-S

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro to create new sheets with numbers in sequence

    try it
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Macro to create new sheets with numbers in sequence

    Is there a way of doing the same thing but instead of creating a blank sheet - copying the last one so that all the formulas are included as well and then renaming the sheet and cell A1 accordingly?
    Yes:

    Please Login or Register  to view this content.
    Sorry, not Excel savy enough to know what "a template that's populated by different rows from a master dataset (tab)" is... :-S
    Attach a sample workbook with just a few tabs, devoid of any sensitive data if need be, and I'll have a look for you.

    Regards,

    Robert

  8. #8
    Registered User
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Macro to create new sheets with numbers in sequence

    Quote Originally Posted by Trebor76 View Post
    Attach a sample workbook with just a few tabs, devoid of any sensitive data if need be, and I'll have a look for you.

    Regards,

    Robert
    Hi Robert,

    Thanks, this works like a charm :-)

    Here is a basic concept of my workbook:

    Example workbook.xlsx

    Thanks again!

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Macro to create new sheets with numbers in sequence

    Hi canflyer,

    Thanks for the feedback and adding to my reputation

    Have a look at the attached where I've created a DataMatrix tab that the Template uses to fetch data from based on the drop-down in cell D2 of that tab (which is automatically refreshed each time it is selected). You can see it when you select between the two agreement numbers from the drop-down. I haven't coded the payment schedule.

    The big advantage with this approach is that you'll only ever need two tabs!!

    If you could please mark the thread as solved it would also be appreciated.

    HTH

    Robert
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    08-20-2013
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Macro to create new sheets with numbers in sequence

    Hi Robert,

    Not a problem, you earned it!

    First off - thank you for introducing me to the drop down menu - I did not know of it till today. How do you insert and program it?

    Secondly - if I do go with this option how does the main spreadsheet pull through the values needed? As all details are under one sheet ("Template").

    Thanks for your extra help! :-)

  11. #11
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Macro to create new sheets with numbers in sequence

    First off - thank you for introducing me to the drop down menu - I did not know of it till today. How do you insert and program it?
    The Data Validation option is found on the Data Tools tab from the Data ribbon. As the data is in a different tab (DataMatrix) from the validation resides (Template) I created a named range that automatically sets itself each time the Template tab is selected.

    Secondly - if I do go with this option how does the main spreadsheet pull through the values needed? As all details are under one sheet ("Template").
    I created VLOOKUP formulas to return the data from the DataMarix tab based on the data validation selection I included in cell B2 of the Template tab.

    HTH

    Robert

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to add missing numbers in a sequence
    By webfeet2 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-10-2015, 10:34 AM
  2. [SOLVED] macro create csv file and name it follow sequence
    By ck_123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2013, 07:01 AM
  3. Macro to Autofill down numbers in Sequence order.
    By awagenhurst in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2013, 07:57 AM
  4. [SOLVED] Creating a sequence based on numbers in one column and adding "01,02..." to a new sequence
    By JCR1968 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-05-2013, 08:06 AM
  5. Replies: 6
    Last Post: 08-02-2006, 11:40 AM

Tags for this Thread

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