Next available number in column

Ana_P

New Member
Joined
Aug 22, 2019
Messages
35
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have an excel s/sheet with order numbers in one column that I would like to prefill based on the next available number in that column.

A few things to note:
- the numbering is a 5 digit number with the first 2 digits being the year the order is in (i.e. 22) followed by 001, 002 etc
- if an order contains multiple items it will use the same order number therefore the next available number will be overridden to accommodate this
- I need the formula to keep working in subsequent rows even if the previous row was overridden per above point
- the data set is in a table
- the numbers aren't in order in the table as the table is sorted by different columns at different times

Any help would be greatly appreciated.

Thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
I think that a couple of things would help you get some sort of suggestion

  1. Update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

  2. MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

    Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
I think that a couple of things would help you get some sort of suggestion

  1. Update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

  2. MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

    Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
Hi Peter

I have now updated my account details. Also, I did try to use XL2BB with my original post however it disabled macros on my laptop and when I clicked the add in to follow the steps required, the options of the add-in were greyed out.

Thanks
 
Upvote 0
CWOB.xlsx
ABCD
1Date RaisedDate Delivered to GDF/YCWO
218/10/2118/01/22Y21556
318/10/2118/01/22Y21556
418/10/2118/01/22Y21556
518/10/2118/01/22Y21556
618/10/2118/01/22Y21556
73/11/2129/10/21F21586
83/11/2129/10/21F21586
93/11/2118/01/22F21586
103/11/2118/01/22F21586
113/11/2118/01/22F21586
July-Dec 2022
Cells with Data Validation
CellAllowCriteria
A2:B602Date>1/01/1900
C2:C602List=Reference!$A$3:$A$7
 
Upvote 0
Thanks for updating your version details and glad that you got XL2BB working. (y)

Still, I assume that you are trying to produce the numbers in column D but I have no idea how they are arrived at - apart from I can see why the first 2 digits are "21" in each case.
But ..
  • How do you come up with 556 for the ending in row 2 given that you said
    followed by 001, 002 etc
    That is, why isn't row 2 "21001"?

  • How do you determine that rows 3, 4, 5 & 6 all keep that same ending? You did say "if an order contains multiple items it will use the same order number", but from the sample data, how do we determine where an order starts and finishes?

  • How do you determine that the ending in row 8 changes from 556 to 558?
 
Upvote 0
Thanks for updating your version details and glad that you got XL2BB working. (y)

Still, I assume that you are trying to produce the numbers in column D but I have no idea how they are arrived at - apart from I can see why the first 2 digits are "21" in each case.
But ..
  • How do you come up with 556 for the ending in row 2 given that you said

    That is, why isn't row 2 "21001"?

  • How do you determine that rows 3, 4, 5 & 6 all keep that same ending? You did say "if an order contains multiple items it will use the same order number", but from the sample data, how do we determine where an order starts and finishes?

  • How do you determine that the ending in row 8 changes from 556 to 558
Hi Peter

The few rows selected are just a snippet of the data in my data table. So the first order of each calendar year will be Year followed by 001, e.g. first order raised in 2022 will be 22001.

As also mentioned in the initial post, the data is sorted on different columns and therefore the order numbers won't be in order in column D (I.e. CWO column).

As for where an order starts and finishes, that all depends on each customer and each order placed - it's not a given and hence why I said the formula will need to be overridden in that case. Which as I typed that realised may be an issue since its a table format and columns autocalculate! I'm thinking if it's the same Customer (data entered in a column further across the table) with the same "Date Raised" (column A) then it would have the same CWO (column D).

Would you have any suggestions as to how to make it work or are you thinking it's not possible?

Thanks
 
Upvote 0
If you want the numbers to remain the same even when the data is sorted differently then that may not be possible with a formula approach. However, that may depend on just what information that you have in your table. Would need to see some of that - all columns- (with any sensitive data disguised) to help decide.
 
Upvote 0
If you want the numbers to remain the same even when the data is sorted differently then that may not be possible with a formula approach. However, that may depend on just what information that you have in your table. Would need to see some of that - all columns- (with any sensitive data disguised) to help decide.
Sample.xlsx
ABCDEFGHIJKLMN
1Date RaisedDate DeliveredF/YCWOFinisherAdd LTCustomerCustomer POCommentsDue DateRevised ETASchedule DateSchedule WeekDate Received
218/10/2118/01/22Y21556ABABC1/02/221/02/2254/02/22
318/10/2118/01/22Y21556ABABC1/02/221/02/2254/02/22
418/10/2118/01/22Y21556ABABC1/02/221/02/2254/02/22
518/10/2118/01/22Y21556ABABC1/02/221/02/22528/02/22
618/10/2118/01/22Y21556ABABC1/02/221/02/22531/03/22
73/11/2129/10/21F21586ABDEF12/11/2112/11/214525/02/22
83/11/2129/10/21F21586ABDEF12/11/2112/11/214518/03/22
93/11/2118/01/22F21586ABDEF1/02/221/02/22515/02/22
103/11/2118/01/22F21586ABDEF1/02/221/02/22517/02/22
113/11/2118/01/22F21586ABDEF1/02/221/02/22521/02/22
123/11/2118/01/22F21586ABDEF1/02/221/02/22525/02/22
1315/11/2124/11/21Y21611ABABCIn Stock8/12/218/12/214931/01/22
1416/11/2117/11/21F21613ABYZ1/12/211/12/214827/01/22
1516/11/2117/11/21F21613ABYZ1/12/211/12/214828/01/22
1616/11/2117/11/21F21613ABYZ1/12/211/12/21483/02/22
1717/11/2130/11/21F21625ABGHIETA 30/1114/12/2114/12/215028/01/22
1822/11/2122/11/21Y21632ABGHI6/12/216/12/214918/02/22
1924/11/2124/11/21Y21642ABABC8/12/218/12/214931/01/22
2024/11/2124/11/21Y21642ABABC8/12/218/12/214931/01/22
2124/11/2124/11/21Y21642ABABC8/12/218/12/214931/01/22
2224/11/2124/11/21Y21642ABABC8/12/218/12/214928/02/22
2324/11/2124/11/21Y21642ABABC8/12/218/12/214928/02/22
2424/11/2124/11/21Y21642ABABC8/12/218/12/214931/03/22
2524/11/2124/11/21Y21642ABABC8/12/218/12/21498/04/22
261/12/2118/01/22F21656ABHS1/02/221/02/2254/02/22
272/12/212/12/21Y21662ABIR16/12/2116/12/215028/02/22
282/12/212/12/21Y21662ABIR16/12/2116/12/21502/03/22
292/12/212/12/21Y21662ABIR16/12/2116/12/215031/03/22
302/12/212/12/21Y21662ABIR16/12/2116/12/215031/03/22
313/12/213/12/21F21663ABJKL17/12/2117/12/21503/02/22
326/12/216/12/21F21669ABYZ20/12/2120/12/215125/01/22
336/12/216/12/21Y21671ABABC20/12/2120/12/215128/02/22
346/12/216/12/21Y21673ABGHI20/12/2120/12/21514/02/22
3515/12/218/12/21F21677ABEV22/12/2122/12/21511/02/22
3615/12/218/12/21F21677ABEV22/12/2122/12/215111/02/22
3715/12/218/12/21F21677ABEV22/12/2122/12/215111/02/22
389/12/219/12/21F21679ABYZ23/12/2123/12/215127/01/22
399/12/219/12/21F21679ABYZ23/12/2123/12/215128/01/22
409/12/219/12/21F21679ABYZ23/12/2123/12/215115/02/22
4110/12/2110/12/21F21680ABJKL24/12/2124/12/215118/01/22
4214/12/2114/12/21F21686ABJKL28/12/2128/12/215227/01/22
4314/12/2114/12/21F21686ABJKL28/12/2128/12/215227/01/22
4414/12/2114/12/21F21686ABJKL28/12/2128/12/215227/01/22
4514/12/2114/12/21F21686ABJKL28/12/2128/12/21523/02/22
4614/12/2114/12/21B21687CDFU8/02/228/02/2264/02/22
4714/12/2114/12/21F21688CDGHI28/12/2128/12/215224/01/22
4816/12/2116/12/21F21696ABGHI30/12/2130/12/215228/01/22
4916/12/2116/12/21F21699CDGHI30/12/2130/12/21524/02/22
5017/12/2119/01/22Y21700ABMNO2/02/222/02/22518/02/22
5117/12/2119/01/22Y21700ABMNO2/02/222/02/22528/02/22
5217/12/2117/12/21F21701ABPQR31/12/2131/12/21523/02/22
5317/12/2117/12/21F21702ABABC31/12/2131/12/21521/02/22
July-Dec 2022
Cell Formulas
RangeFormula
L2:L53L2=IF(ISBLANK([@[Revised ETA]]),[@[Due Date]],[@[Revised ETA]])
M2:M53M2=IF(OR([@[Schedule Date]]="",[@[Schedule Date]]="Missing Info"),"",ISOWEEKNUM([@[Schedule Date]]))
J2:J53J2=IF(ISBLANK([@[Date Raised]]),"",IF(OR(ISBLANK([@[Date Delivered]]),ISBLANK([@[F/Y]])),"Missing Info",[@[Date Delivered]]+VLOOKUP([@[F/Y]],Lead_Time,3,FALSE)+[@[Add LT]]))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I2:I601Expression=AND($Q2="Open",ISNUMBER(SEARCH("ASAP",$I2)))textNO
I2:I601Expression=AND($Q2="Open",ISNUMBER(SEARCH("Urgent",$I2)))textNO
I2:I601Expression=AND($Q2="Open",ISNUMBER(SEARCH("Repro",$I2)))textNO
L2:M601Expression=AND($Q2="Open",$M2<Current_Week)textNO
J2:J601Expression=ISNUMBER($K2)textNO
Cells with Data Validation
CellAllowCriteria
J2:L53Date>1/01/1900
N2:N53Date>1/01/1900
A2:B601Date>1/01/1900
C2:C601List=Reference!$A$3:$A$7
E2:E601List=Reference!$A$15:$A$17
F2:F601Whole numberbetween 0 and 99
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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