Help With Serial Number Sequential Orders in a Multiple Serial Number doc

brsnyder1

New Member
Joined
Nov 15, 2018
Messages
9
I have a document that I track multiple serial numbers of reports. The trick is that reports initiated by our company have a unique serial number (N00164-18-0001) and reports that are initiated by outside users have a different serial number so the excel spreadsheet has mixed reports going down the list. When I initiate a new report, I have to go back through all the report numbers and verify the next sequential report serial number (N00164-18-0002). I want to make a "Next Report Serial Number" next to my table and I'm looking to see if there is a way to sequentially be able to see what the next report number should be. I only need to track our companies next report serial number. I hope this makes sense and someone has the answer on how to sequentially generate the next serial number even if the report numbers have different serial numbers mixed in with them. Thank you!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Maybe I can simplify the question so I can get some answers.

I have a list of serial numbers
N00164-18-001
R90794-18-0024
N00164-18-002
V35053-18-2003

List continues to go on in cronological order as the reports come in. All the N00164 reports are serial numbers that we initiate. I need to be able to see what the next serial number is in sequence and have it auto populate either in a cell off to the side that is labeled "Next Serial" or when I begin to type N00164 in the cell then it auto generates in the box with the next sequential number. Trying to alleviate having to filter back through all the report numbers to find the last one our company initated.
 
Upvote 0
Try this "Double Click Event" in column "A"
To load code:-
Right click sheet "Tab", from DropDown select "View Code", vbwindow appears.
Paste code into VbWindow, Close Vbwindow.

To run code Double Click empty cell in columns "A"
NB:-There must be at least on cell in column"A" with a "N00164" serial number.
Code:
Private [COLOR="Navy"]Sub[/COLOR] Worksheet_BeforeDoubleClick(ByVal Target [COLOR="Navy"]As[/COLOR] Range, Cancel [COLOR="Navy"]As[/COLOR] Boolean)
 [COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, temp [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String,[/COLOR] Sp [COLOR="Navy"]As[/COLOR] Variant

 [COLOR="Navy"]If[/COLOR] Target.Column = 1 And Target.Value = "" [COLOR="Navy"]Then[/COLOR]
    [COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
        [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
           [COLOR="Navy"]If[/COLOR] Left(Dn.Value, 6) = "N00164" [COLOR="Navy"]Then[/COLOR]
              temp = Dn.Value
            [COLOR="Navy"]End[/COLOR] If
   [COLOR="Navy"]Next[/COLOR] Dn
    Sp = Split(temp, "-")
    Target.Value = Sp(0) & "-" & Sp(1) & "-" & Format(Sp(2) + 1, "000")
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Hi,

You can either Manually type the Next Serial as identified by D2, or Copy/Paste Value from D2 in Column A, D2 will auto populate the Next Serial as you Add:


Book1
ABCD
1N00164-18-001Next Serial Report #
2R90794-18-0024N00164-18-004
3N00164-18-002
4V35053-18-2003
5N00164-18-003
Sheet357
Cell Formulas
RangeFormula
D2="N00164-18-"&TEXT(COUNTIF(A1:A100,"N00164-18*")+1,"000")
 
Upvote 0
I'm an Excel newbie, could you possibly break it down for me? Sorry! I'm having trouble trying to figure out how to load the code
 
Upvote 0
So if my serial number currently is at N00164-18-5001 how do i start the function to count from 5001? does that change the formula?
 
Upvote 0
Would this do it for you?


Book1
ABCD
1N00164-18-5001Next Serial Report #
2R90794-18-0024N00164-18-5004
3N00164-18-5002
4V35053-18-2003
5N00164-18-5003
Sheet357
Cell Formulas
RangeFormula
D2="N00164-18-5"&TEXT(COUNTIF(A1:A100,"N00164-18-5*")+1,"000")
 
Upvote 0
[Table="width:, class:grid"][tr][td="bgcolor:#C0C0C0"][/td][td="bgcolor:#C0C0C0"]
A​
[/td][td="bgcolor:#C0C0C0"]
B​
[/td][/tr][tr][td="bgcolor:#C0C0C0"]
2​
[/td][td]N00164-18-5001[/td][td]<< Input[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
3​
[/td][td]N00164-18-5002[/td][td]<< Dragged down[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
4​
[/td][td]N00164-18-5003[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
5​
[/td][td]N00164-18-5004[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
6​
[/td][td]N00164-18-5005[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
7​
[/td][td]N00164-18-5006[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
8​
[/td][td]N00164-18-5007[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
9​
[/td][td]N00164-18-5008[/td][td][/td][/tr]
[/table]
 
Upvote 0
Adjust your range in the formula accordingly!

In the formula in # 5 the range is assumed to be until 100th row! But I guess 100000 would be sufficient! So use the formula as

="N00164-18-"&TEXT(COUNTIF(A1:A100000,"N00164-18*")+1,"0000")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top