+ Reply to Thread
Results 1 to 9 of 9

Macro For Unique Sequential Numbering on multiple sheets

Hybrid View

  1. #1
    Registered User
    Join Date
    10-25-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Macro For Unique Sequential Numbering on multiple sheets

    Hello,

    I fear the answer to this may be easy, but I have yet to find a solution that works so I am hoping someone can help me out. I have a workbook that contains 4 worksheets that each have identical column headings. I also have a userform that inputs data into each of these worksheets depending on which category is selected on the userform. Where there is a difference is in their numbering structure. Sheet 1 is 1,2,3,4,5,etc. Sheet 2 is A1,A2,A3,etc. Sheet 3 is N1,N2,N3,etc and so on. What I would like to do is have the enteries auto number as the data is entered into them via the userform. The data from the userform is entered into columns B-K and the number of the entry is in column A. Currently I am using the dragdown feature to autonumber them once they are entered on the form. Any help here would be much appreciated.

    Thanks

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro For Unique Sequential Numbering on multiple sheets

    Hi, dkannapel,

    use a custom format for the cells in COlumn A of the sheets, for Sheet3 this may look like
    Formula: copy to clipboard
    "N"#

    The code to add a new unique number to Sheet3 may look like
    With Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp)
      .Offset(1, 0).Value = WorksheetFunction.Max(Range("a2", .Address)) + 1
    End With
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    10-25-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Macro For Unique Sequential Numbering on multiple sheets

    Holger,

    Thank you for the quick reply. The code you provided almost works perfectly. What I did find, however is that once the userform was closed and reopened the numbering starts again at 1 (i.e if the last entry was numbered A5 when the userform was closed, the next entry once the userform was opened and data entered was numbered A1). What I did find that has worked, mostly, is a combination of what you suggested and another bit of code I had that was part of my earlier attempts:

    I used the custom formatting for Column A of all the worksheets like you suggested. I then used the code:

    Set rng = Cells(Rows.Count, 1).End(xlUp)
    rng.Offset(1) = rng + 1
    This works great on all the worksheets but one, which has me really confused as to why. All of the worksheets are formatted the same way (except column A which has the custom numbering format) yet when I try to enter the data into Sheet6 it returns a 'Type Mismatch' error at the "rng.offset" line of code. I was hoping you could possibly point me in the direction to try to debug it. Everything I have tried so far has not worked. Thank you in advance for your help.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro For Unique Sequential Numbering on multiple sheets

    Hi, dkannapel,

    this is one of the rare occasions where I would like to have a look at the workbook as I have no clue right now what may be going wrong.

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    10-25-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Macro For Unique Sequential Numbering on multiple sheets

    Holger,

    Here is a copy of the workbook. All of the data is just jibberish at this point as I go through with testing the different additions I make. Again, I really appreciate your help on this.



    Thanks
    Attached Files Attached Files
    Last edited by dkannapel; 07-03-2014 at 11:58 AM.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro For Unique Sequential Numbering on multiple sheets

    Hi, dkannapel,

    if Iīm correct Excel has some difficulties in finding a Max value for Strings as A2 to A4 are String with the K being part of the cell instead of being part of the formatting. So if you run the code with Near Miss the forst available number is 1 as the Max-Function wonīt work with Strings and would return 0.

    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    10-25-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Macro For Unique Sequential Numbering on multiple sheets

    Holger,

    Maybe I'm missing something here, but then aren't the other values is sheets JSA and AI strings as well as they are A1 and J1? If they are then they should have the same problem as the near miss sheet, no? What confuses me is they dont, they work just fine. It is only the near miss sheet.

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro For Unique Sequential Numbering on multiple sheets

    Hi, dkannapel,

    donīt be irritated by whatīs diplayed in the cell. Press F2 and see that itīs only a number which is displayed there which will serve the Max.

    Ciao,
    Holger

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,633

    Re: Macro For Unique Sequential Numbering on multiple sheets

    Try change to
    'Add 1 to CAPA Number
    With Cells(Rows.Count, 1).End(xlUp)
        .AutoFill .Resize(2), xlFillSeries
    End With
    
    'The the Controls for the Next Entry

+ 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. Sequential Numbering of a Form Printed Multiple Times
    By MMRANCH02 in forum Excel General
    Replies: 4
    Last Post: 04-02-2014, 03:53 PM
  2. Sequential Numbering and Unique Reference Codes
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2014, 08:35 AM
  3. [SOLVED] Sequential Numbering Macro
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 03-09-2014, 08:51 AM
  4. [SOLVED] Sequential numbering within range for multiple criteria
    By jakestyeen7059 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-14-2013, 03:19 PM
  5. Sequential Numbering Macro
    By stedia in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-18-2007, 01:10 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