+ Reply to Thread
Results 1 to 8 of 8

Macro to create 12 sheets with predetermined names

  1. #1
    Registered User
    Join Date
    05-24-2018
    Location
    Canada
    MS-Off Ver
    Windows 7
    Posts
    35

    Macro to create 12 sheets with predetermined names

    Hi,

    Assuming I would like to create 12 sheets (months of the year).
    How would i look over a function to create those sheets in the most concise way possible.

    Thank you

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Macro to create 12 sheets with predetermined names

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 10-11-2018 at 01:29 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    05-24-2018
    Location
    Canada
    MS-Off Ver
    Windows 7
    Posts
    35

    Re: Macro to create 12 sheets with predetermined names

    Quote Originally Posted by mehmetcik View Post
    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Does not work. Run-time error '1004':
    That name is already taken. try a different none.
    Shouldnt i create an array first like:
    Tabs = ("JANUARY", "FEBRUARY", ...,"X")
    and then a for loop through tabs ?

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Macro to create 12 sheets with predetermined names

    Please Login or Register  to view this content.
    This is based on US date format. For European format change to Format("1/" & i & "/2018", "mmmm")
    Last edited by JLGWhiz; 10-11-2018 at 01:13 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Macro to create 12 sheets with predetermined names

    Try These Instead

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Macro to create 12 sheets with predetermined names

    Another option
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-24-2018
    Location
    Canada
    MS-Off Ver
    Windows 7
    Posts
    35

    Re: Macro to create 12 sheets with predetermined names

    Quote Originally Posted by Fluff13 View Post
    Another option
    Please Login or Register  to view this content.
    can you please explain the i*29 as an expression and the need to write 'i' after next?
    thank you sir

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Macro to create 12 sheets with predetermined names

    You don't need to put the i after Next, I just prefer it. Especially if you have nested loops as it shows clearly which loop you are referring to.

    The i*29 simply gives you a number, which is effectively converted to a date & then formatted to give the month.
    So when i is 1 i*29 is 29 which becomes 29 jan 1900
    If i=2 the date is 27 Feb 1900 etc.

    Thanks for the rep

+ 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. [SOLVED] VBA to create separate sheet with sheets names and count
    By Tyso in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2018, 03:53 PM
  2. [SOLVED] Create Sheets and copy rows to the Sheets if cell contains sheet names
    By CRIMEDOG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-08-2015, 08:06 AM
  3. [SOLVED] Add new worksheets depending on a list with predetermined names
    By Masun in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 07-20-2013, 07:35 AM
  4. Replies: 17
    Last Post: 02-01-2013, 12:20 PM
  5. [SOLVED] Random selection of names with no duplicates and ignoring a predetermined name list
    By iain.excel in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-16-2012, 06:51 PM
  6. Using a list of names to create new sheets as a template
    By GreggDavey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-24-2010, 09:44 AM
  7. Replies: 4
    Last Post: 05-28-2005, 02:05 PM

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