+ Reply to Thread
Results 1 to 17 of 17

New Worksheet with sequence number

  1. #1
    Registered User
    Join Date
    06-06-2014
    Posts
    12

    New Worksheet with sequence number

    Hi,

    I have a problem to name correctly my new worksheet in order to obtain a sequence.
    So my first worksheet' name is 3114
    my macro is
    Please Login or Register  to view this content.
    And I don't know what I have to put after Name = ... to obtain the sequence, what means that the next worksheet is 3115, the next one 3116 etc.

    I tried with Worksheet.Count but it puts the number of sheet starting from 1 ...
    Thank you ,
    Regards,
    Last edited by kamila1704; 06-06-2014 at 07:57 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: New Worksheet with sequence number

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  3. #3
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: New Worksheet with sequence number

    try this

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: New Worksheet with sequence number

    Hi,

    I'd be inclined to hold the next sheet number as a variable in a named cell. Enter 3115 in a cell and name the cell 'NextSheet'

    Now use the following macro
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    06-06-2014
    Posts
    12

    Re: New Worksheet with sequence number

    It's working only for 3115, but I wanted the sequence 3115,3116 etc...

  6. #6
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: New Worksheet with sequence number

    use this code then

    Please Login or Register  to view this content.
    it will go find the highest value sheetname, create a copy, rename the new sheet with an increment

  7. #7
    Registered User
    Join Date
    06-06-2014
    Posts
    12

    Re: New Worksheet with sequence number

    It's working ! Thanks !
    My God it's too complicate this code ! I spent half of day to try this one...

  8. #8
    Registered User
    Join Date
    06-06-2014
    Posts
    12

    Re: New Worksheet with sequence number

    I have another question... if in my worksheet 3114 was a cell name 1, if it's possible that in new created worksheet 3115 this cell change to 2 ?

    I tried this, but it doesn't work

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: New Worksheet with sequence number

    think this will work

    Please Login or Register  to view this content.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: New Worksheet with sequence number

    Hi,

    Are you sure you have named a cell somewhere "NextSheet" and populated it with the initial value of 3115.
    When I do that and run the macro, each time its run I see a new sheet, 3115, 3116, 3117 etc..

    Please Login or Register  to view this content.
    But let me ask a more fundamental question. What are you going to use the information on the sheet for. At some stage are you going to want to know say the totals for many sheets, or be able to select specific records from several sheets? In which case I would suggest you capture your data on a single sheet but with a new column added that contains the 3114, 3115 reference on each record row.

    This will allow you to build a proper database that will be far more useful and allow you to use the powerful pivot table fiunctionality.

  11. #11
    Registered User
    Join Date
    06-06-2014
    Posts
    12

    Re: New Worksheet with sequence number

    Not really ... it gives the numbers : 1, 3, 5 and in one click it creates two worksheets

  12. #12
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: New Worksheet with sequence number

    Quote Originally Posted by kamila1704 View Post
    I have another question... if in my worksheet 3114 was a cell name 1, if it's possible that in new created worksheet 3115 this cell change to 2 ?

    I tried this, but it doesn't work

    Please Login or Register  to view this content.
    ignore my latest reply, misunderstood your question
    in the sheet you are copying, it will have data, 2 secs and i'll post some new code

  13. #13
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: New Worksheet with sequence number

    this does what you wanted now

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    06-06-2014
    Posts
    12

    Re: New Worksheet with sequence number

    I tried also this but with this method you can't create 3116, 3117 etc

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    Are you sure you have named a cell somewhere "NextSheet" and populated it with the initial value of 3115.
    When I do that and run the macro, each time its run I see a new sheet, 3115, 3116, 3117 etc..

    Please Login or Register  to view this content.
    But let me ask a more fundamental question. What are you going to use the information on the sheet for. At some stage are you going to want to know say the totals for many sheets, or be able to select specific records from several sheets? In which case I would suggest you capture your data on a single sheet but with a new column added that contains the 3114, 3115 reference on each record row.

    This will allow you to build a proper database that will be far more useful and allow you to use the powerful pivot table fiunctionality.

  15. #15
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: New Worksheet with sequence number

    Quote Originally Posted by kamila1704 View Post
    Not really ... it gives the numbers : 1, 3, 5 and in one click it creates two worksheets
    Then I suspect you must be doing something different.

    See attached.

    Tell me what you see when you click the 'Run Sheet Add Macro' button
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    06-06-2014
    Posts
    12

    Re: New Worksheet with sequence number

    It's ALMOST working , just there is a little problem and I can't see it in your code.
    In example my worksheet is 3152, when I make working my macro , it creates in the same time 3153 and 3154 and only 3154 change the number on the cell H2..

    Quote Originally Posted by ThirtyTwo View Post
    this does what you wanted now

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    06-06-2014
    Posts
    12

    Re: New Worksheet with sequence number

    Sorry !! It's working!! You are the best !!

+ 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 Copy a set of Data from one Worksheet to Another Worksheet with same Sequence
    By Rajeshkumar R in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2014, 02:56 AM
  2. Replies: 6
    Last Post: 11-26-2013, 05:21 PM
  3. Replies: 5
    Last Post: 11-22-2010, 06:31 PM
  4. VBA Code To Mirror Cells from one Worksheet to another based on sequence number
    By jarrinsonp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-29-2010, 06:28 AM
  5. How can I match a random number with closest number from sequence?
    By matt in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-02-2006, 08:25 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