+ Reply to Thread
Results 1 to 4 of 4

Excel function for sequential numbering with the same reference

  1. #1
    Registered User
    Join Date
    04-28-2022
    Location
    Philippines
    MS-Off Ver
    2013
    Posts
    1

    Post Excel function for sequential numbering with the same reference

    What is the function for sequential numbering with the same reference? It is really hard to do it manually. Any help will be greatly appreciated. Photo attached is the sample. Thank you
    Attached Images Attached Images
    Last edited by asdfghjklu; 04-28-2022 at 01:56 PM.

  2. #2
    Valued Forum Contributor PeteABC123's Avatar
    Join Date
    09-21-2012
    Location
    Chicago, IL
    MS-Off Ver
    MS Office 365 ver 2202
    Posts
    1,104

    Re: Excel function for sequential numbering with the same reference

    Hi asdfghjklu, Welcome to the forum.

    Ya might try this. . .using helper columns.
    In B2 enter 1205 don't copy down
    In B3 enter =IF(A3=A2,B2,B2+1) copy down
    In C2 enter ="IN "&B2. Copy down

    For empty rows use the Iferror function to hide the error.

    Let us know.

    Pete

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Excel function for sequential numbering with the same reference

    Assuming I understand correctly, the hardest part is that column B is text and Excel does not know how to add 1 to text. Again, assuming I understand, here's how I might approach this:

    1) Enter 1205 in B2
    2) In B3, enter the formula =IF(A2=A3,B2,B2+1)
    3a) If the number is acceptable as an output, I can add the "IN " using number formatting. A custom number format code like "IN "General or "IN "0 (custom number code help file: https://support.microsoft.com/en-us/...rs=en-us&ad=us ) Be sure to understand that the IN is only part of the displayed value, but it is not part of the actual cell value (sometimes spreadsheets cause confusion when a number format causes the display to be very different from the cell's actual value).
    3b) If the final result must be text, then I would do the concatenation to text in a separate column. In C2, enter ="IN "&B2. Copy/paste/fill down as far as needed. In this case, be clear that the value in column B is a number and the value in column C is text. Column B will be more useful for numeric manipulations (like adding 1 when needed).

    Does something like that help?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Valued Forum Contributor
    Join Date
    11-22-2014
    Location
    Arizona, USA
    MS-Off Ver
    Office 365
    Posts
    973

    Re: Excel function for sequential numbering with the same reference

    So the if Current Row value is equal to last row value then repeat last ID approach is valid... but this is highly dependent on the data be sorted correctly at all times...

    And we are on row 2 but you are already on ID 1205... How are you getting this value to start with... does the receipt belong to another data set that contains such an ID?

    I think what has been offered will generate next ID correctly provided your data is sorted appropriately and there is no chance that it will be sorted again... I say this because the ID is moot if you have to keep sorting... one day someone may put receipt 10124 500 rows down...and it will get a new ID rather than find the previous ID... to which you may want to error trap yourself and colleagues alike.

    B2=VLOOKUP($A2,$A$1:$B1,2,False)

    Now this will find previous entries above current record and return the same record... but if it does not exist... ERROR "#N/A"

    So Trap that, what do we want to do when that happens? well we want it to get the MAX of the ID's that have been used and add 1 to it... But this requires a bit of MrShorty's trick in which you visually represent the IN through a custom format so we can get the max... OR you put a helper column in that has the numeric portion of the text only..

    MrShortys use of formats will allow this to work
    B2 = IFERROR(VLOOKUP($A2,$A$1:$B1,2,False),MAX($B$1:$B1)+1)

    Now wait a minute... it needs one more error trap... because the FIRST ID will be an error... it wont find a previous entry and there is no MAX, so wrap that little guy in one more iferror to set 1 as the first ID

    B2 = IFERROR(IFERROR(VLOOKUP($A2,$A$1:$B1,2,False),MAX($B$1:$B1)+1),1)


    If you make a "Helper" Column you would need to sort out your way of getting the numeric portion of the string...Being that it is a fixed format a simple

    =RIGHT(B2,LEN(B2)-3)

    Would do it. Why -3? well we know that the first 3 CHAR in your string is "IN " and that space counts so you want everything to the right of the first 3 characters...

    You could go over the top and strip the string of everything that is not text

    =TEXTJOIN("",TRUE,IFERROR((MID(B2,ROW(INDIRECT("1:"&LEN(B2))),1)*1),""))

    Any way that you do it... you will need to update the reference of MAX($B$1:$B1) to be the column you drop the HELPER column in.
    -If you think you are done, Start over - ELeGault

+ 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. excel grid sequential numbering
    By mic d in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-24-2019, 12:19 AM
  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. Sequential Numbering in Excel within specified Range
    By Ariff_Chowdhury in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2013, 11:16 AM
  4. Can I set up sequential numbering in a colum in excel
    By Quitefriendly1 in forum Excel General
    Replies: 4
    Last Post: 06-21-2006, 08:50 PM
  5. In Excel, how do I setup sequential numbering on an invoice?
    By Kostumeroom in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-19-2005, 08:05 PM

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