+ Reply to Thread
Results 1 to 10 of 10

Auto create and name sheet

  1. #1
    Registered User
    Join Date
    08-07-2015
    Location
    Washington
    MS-Off Ver
    365, v1808 32bit
    Posts
    59

    Auto create and name sheet

    I am writing a macro where when the user clicks a button, it will add a new sheet and automatically draw up a template. I want it where the new sheet is created it's named "Panel (1)" simple enough, however, if they click the add panel button again, I want the next sheet to be named "Panel (2)" and so forth.

    If I use this at the beginning of my code, it will create the new sheet named "Panel (1)"

    Please Login or Register  to view this content.
    But when I try again to add a new sheet, I get an error that the sheet name already exists, and I can't figure out how to make the numerical value add +1 to the last pre-existing sheet created.

    Thoughts?

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

    Re: Auto create and name sheet

    You can either store the last panel number in a cell in the workbook

    Or you can actively look for the last panel sheet number in the workbook.
    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
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Auto create and name sheet

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Auto create and name sheet

    Hi there,

    See if the following code does what you need:

    Please Login or Register  to view this content.
    The highlighted values can be altered to suit your own requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  5. #5
    Registered User
    Join Date
    08-07-2015
    Location
    Washington
    MS-Off Ver
    365, v1808 32bit
    Posts
    59

    Re: Auto create and name sheet

    Quote Originally Posted by mehmetcik View Post
    Please Login or Register  to view this content.
    Thank you, this seems to work great!

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Auto create and name sheet

    Hi again,

    Many thanks for the Reputation increase - much appreciated!

    Best regards,

    Greg M

  7. #7
    Registered User
    Join Date
    08-07-2015
    Location
    Washington
    MS-Off Ver
    365, v1808 32bit
    Posts
    59

    Re: Auto create and name sheet

    I could use a little more help if you don't mind. I am also trying to add a button that will copy an active sheet and auto name it the same way as above.

    Suppose active sheet is named "Qty (1)", when the user clicks the button, it will copy the sheet and the new sheet would be named "Qty (2)" and so forth. No matter what sheet they copy, I want the new sheet to always be named Qty (+1 to last sheet that was created) every time.

    I tried using the same coding you provided me for the panel sheets and changed to the following:


    Please Login or Register  to view this content.
    It will work once and create a "QTY (1)" sheet, but when I try it again, I get a "run-time error '1004: That name is already taken. Try a different one."

    Do I need to change any other values in the code above to achieve this?

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Auto create and name sheet

    As long as the right most sheet is the last "Qty" sheet, this should work.
    Please Login or Register  to view this content.
    In your last Post you mention copying a sheet but your code says to add a new sheet.
    I took it to be adding a new sheet.

  9. #9
    Registered User
    Join Date
    08-07-2015
    Location
    Washington
    MS-Off Ver
    365, v1808 32bit
    Posts
    59

    Re: Auto create and name sheet

    Quote Originally Posted by jolivanes View Post
    As long as the right most sheet is the last "Qty" sheet, this should work.
    Please Login or Register  to view this content.
    In your last Post you mention copying a sheet but your code says to add a new sheet.
    I took it to be adding a new sheet.
    Thanks for your help! I need it to copy active sheet and name it accordingly. Also, the sheet will not always be on the right most sheet unfortunately.

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Auto create and name sheet

    Please don't quote.
    Just use the person's handle if you answer a particular poster.

    Please Login or Register  to view this content.

+ 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. auto create new sheets from one sheet
    By LLOYD6664 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-09-2014, 11:52 PM
  2. How do I create an AUTO FILL sheet
    By Irishbshep in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 04-08-2014, 11:24 AM
  3. [SOLVED] Create new sheet from template, auto fill from index sheet and hyperlink
    By RichTea88 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2013, 04:57 AM
  4. [SOLVED] Auto-create and name a new tab, and carry relevant data to new tab, from a master sheet
    By teenyjem in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-05-2013, 03:38 PM
  5. Replies: 4
    Last Post: 05-02-2013, 04:39 PM
  6. Create a master sheet to auto fill many documents.
    By citadel-maritime in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-26-2013, 02:19 AM
  7. How to create auto-populated order sheet
    By lukas989 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-22-2013, 04:48 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