+ Reply to Thread
Results 1 to 10 of 10

Formula to auto-generate next sequential number dependent on document numbering

  1. #1
    Registered User
    Join Date
    08-28-2012
    Location
    Sudbury, ON
    MS-Off Ver
    Excel 2003
    Posts
    5

    Question Formula to auto-generate next sequential number dependent on document numbering

    Hi - been trying to figure this out for some time with no luck! I have scoured the forum and have not found anything that can help.

    Column B is the resulting document number with the unique number (formula already inserted to combine Columns D, E, F and G) - not sure if I need Column B or C for the formula in Column G??
    Column C is the resulting document number without the unique number (formula already inserted to combine Columns D, E and F) - not sure if I need Column B or C for the formula in Column G??
    Column D is the document type (from a drop down menu).
    Column E is the application type (from a drop down menu).
    Column F is the department ID (from a drop down menu).
    Column G is the unique number for the document - this is where I'd like the formula to auto-generate this number based on what is chosen from the drop down menus; document type, application type, department ID - then assign next sequential number.

    Looking for a formula that would auto-generate the number in Column G so that a duplicate document number is not assigned.

    Capture.JPG

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,647

    Re: Formula to auto-generate next sequential number dependent on document numbering

    Welcome to the forum!

    You just need to incorporate a COUNTIFS into your formula. Attach the workbook and then it will be easier for us to help.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: Formula to auto-generate next sequential number dependent on document numbering

    Try in "B2"
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Copy Paste down.


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Formula to auto-generate next sequential number dependent on document numbering

    Or simplifying avk's formula

    =C2&TEXT(COUNTIF(C$2:C2,C2),"000")

    The LEFT function is not needed.

    edit:- then, after posting, I see the number in column G

    In G2

    =TEXT(COUNTIF(C$2:C2,C2),"000")

    In B2

    =C2&G2

    Or, if you're trying to eliminate steps

    =COUNTIFS(D$2:D2,D2,E$2:E2,E2,F$2:F2,F2)

    You should be able to mix and match bits from these to get the desired result in the way that suits best.
    Last edited by jason.b75; 09-16-2018 at 04:30 AM.

  5. #5
    Registered User
    Join Date
    08-28-2012
    Location
    Sudbury, ON
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Formula to auto-generate next sequential number dependent on document numbering

    Thank you all!
    Ended up using Jason.b75's formula and works like a charm.
    Just wondering if the formulas in Columns G and H can be tweaked so that if there is no text in Column C - the result remains blank, rather than showing the below results:
    Capture.JPG

    Much appreciated!

  6. #6
    Registered User
    Join Date
    08-28-2012
    Location
    Sudbury, ON
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Formula to auto-generate next sequential number dependent on document numbering

    Hi avk,

    Tried out your formula as well and also works!
    But same thing as per my previous post, looking to only show results if there is text present.

    Thank you everyone!

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Formula to auto-generate next sequential number dependent on document numbering

    Try

    =IF(COUNT(D2:F2)=3,TEXT(COUNTIFS(D$2:D2,D2,E$2:E2,E2,F$2:F2,F2),"000"),"")

    =IF(G2<>"",D2&"-"&E2&"-"&F2&"-"&G2,"")

    Note that you don't need columns B C and H, just one of them will be sufficient for the formula to work.
    You could even combine the 2 formulas above and do away with column G if desired.

  8. #8
    Registered User
    Join Date
    08-28-2012
    Location
    Sudbury, ON
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Formula to auto-generate next sequential number dependent on document numbering

    Hi Jason.b75,

    Sorry to bother you again, but when I try the formulas you provided, it comes up blank for some reason.
    I've attached the actual .xls file for you.

    I'm okay with eliminating Column C and H, but B needs to remain
    I basically need Column B to show the full document number, D to show the Type ID, E to show the Application ID, F to show the Department ID and G to have the auto-generated Unique Number.

    Thank you so much for your time - very much appreciated!

    Trina
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Formula to auto-generate next sequential number dependent on document numbering

    Part of it was my mistake, I should have used COUNTA which counts text, not COUNT which only counts numbers.

    Now, having seen the workbook, it becomes apparent that the opposite needs to be done and the formula needs to check that there are no blanks rather than checking that all 3 columns contain text.

    The formulas in those columns, which we cannot see from a screen capture, are still classified as text because of the "" that they display, so COUNTA would still count them, which we need to avoid.

    With columns C and H removed, (shifting everything else left).

    In F3

    =IF(COUNTBLANK(C3:E3),"",TEXT(COUNTIFS(C$3:C3,C3,D$3:D3,D3,E$3:E3,E3),"000"))

    In B3

    =IF(F3="","",C3&"-"&D3&"-"&E3&"-"&F3)

    See attached.

    Also simplified the formula in P3 for you (R3 in original file).
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    08-28-2012
    Location
    Sudbury, ON
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Formula to auto-generate next sequential number dependent on document numbering

    You are amazing!!
    Thank you so much!

    Probably would have been easier to attach the .xls file from the get go, but new to the forum and wasn't sure how to do it at first.

    This has saved me so much time - will definitely continue using this forum in the future whenever I get stuck.

    Much appreciated,
    Trina

+ 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. Replies: 2
    Last Post: 08-11-2015, 12:29 PM
  2. Generate Sequential Numbering based on Combobox selection
    By MzBranch in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2015, 01:09 PM
  3. [SOLVED] Generate sequential numbering when cell values are larger than
    By Carlsbergen in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-31-2014, 07:21 AM
  4. [SOLVED] excel 2007 - how do i generate a sequential number within an IF formula?
    By tom BTV in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-16-2012, 09:47 AM
  5. sequential numbering macro - how to stop it increasing when document is saved??
    By mansfieldchris in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-07-2011, 04:55 PM
  6. Auto Generate Sequential Invoice Number
    By jneldon in forum Excel General
    Replies: 1
    Last Post: 03-09-2009, 01:17 PM
  7. Auto Fill/Sequential Numbering
    By tjh in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-01-2006, 10:35 AM

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