+ Reply to Thread
Results 1 to 9 of 9

Generating next number

  1. #1
    Registered User
    Join Date
    07-25-2021
    Location
    USA
    MS-Off Ver
    2019
    Posts
    7

    Generating next number

    I am trying to set up an inventory system for my wife's online sales business. She needs to add an item number to her products so I have established a system that will be 000-00000-00000000 format. The first three numbers and the second five are for tracking location and selling location. The last eight will be used as an item number. Once we use the 0000001 we don't want to use it again. How can I search the row of cells with the item numbers and find the next available number?

    Thanks in advance.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Generating next number

    Can you provide some samples of what you are working with?

    - You could maybe use Data Validation to not allow duplicate values
    - If the entries are real numbers, you could have a cell that returns the MAX of entries
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    07-25-2021
    Location
    USA
    MS-Off Ver
    2019
    Posts
    7

    Re: Generating next number

    So since she is still getting started with the system, some items have numbers and others do not. The format going forward will be a combination of letters and
    numbers with the last eight spots all being numbers. So based on the last eight numbers I want to be able to find the next available number.

    So if column a is the item numbers it looks like below. U am only using the last eight numbers. So in this case I want to generate my next number as 00000003

    A

    row1 m12-0038-00000000
    row2 w9-23-00000000
    row3 -00000000
    row4 m100-epf00-00000001
    row5 w300-ep000-00000002

    I have already made a macro to make blank cells -00000000 so there will be 8 numbers from the right.

    Thanks
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,923

    Re: Generating next number

    Try this

    PHP Code: 
    Public Function Next_Number(rng As Range) As String
    Dim cel 
    As Rangetemp As Long
    For Each cel In rng
        
    If cel.Value Like "*########" Then
            
    If CLng(Right(cel.Value8)) > temp Then temp CLng(Right(cel.Value8))
        
    End If
    Next
    Next_Number 
    Format(temp 1"00000000")
    End Function 

  5. #5
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,923

    Re: Generating next number

    Or try:

    =TEXT(AGGREGATE(14,6,--RIGHT($A$2:$A$9,8),1)+1,"00000000")

  6. #6
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,493

    Re: Generating next number

    So regular

    Cell C2 formula

    HTML Code: 

  7. #7
    Registered User
    Join Date
    07-25-2021
    Location
    USA
    MS-Off Ver
    2019
    Posts
    7

    Re: Generating next number

    Thanks, that worked great. =TEXT(AGGREGATE(14,6,--RIGHT($A$2:$A$9,8),1)+1,"00000000")
    Last edited by Lcarter114; 07-27-2021 at 04:20 PM.

  8. #8
    Registered User
    Join Date
    07-25-2021
    Location
    USA
    MS-Off Ver
    2019
    Posts
    7

    Re: Generating next number

    I tried the Lookup function but I think since the numbers are not all the same format it only gives me back a value of 1

  9. #9
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,493

    Re: Generating next number

    You're Welcome. Thank You for the feedback and for marking the thread as 'Solved'.

+ 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] Self Generating PO Number
    By HarryBasra in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-17-2020, 08:27 AM
  2. [SOLVED] Self Generating Po Number
    By Harry Basra in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-17-2020, 08:22 AM
  3. Replies: 1
    Last Post: 10-03-2017, 10:54 AM
  4. Generating Invoice Number
    By viruzman in forum Excel General
    Replies: 3
    Last Post: 02-09-2008, 02:03 PM
  5. Generating an Identification number
    By Awheeler in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-14-2006, 02:51 AM
  6. Invoice number generating...
    By ChrisMattock in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-12-2006, 08:09 AM
  7. [SOLVED] Generating (in a random order)each number once from a given number
    By Neil Goldwasser in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-02-2005, 07:30 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