Next Available Number in Range

Marhier

Board Regular
Joined
Feb 21, 2017
Messages
128
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Good morning, I hope you're all well today.
I'm trying to find a formula that will give me the next available sequential number in a range of cells.

Use case:
I have an order register with a list of sequential schedule numbers (Column A).
Once an order has been placed, I put the order number in the respective cell in Column O.
I might order schedule 024, before I order schedule 016, so the order numbers aren't typically listed in sequential order.

What I'm After:
In cell V5, I want to put a formula that looks that looks at range O9:O1008 (or PurchaseOrderTable[Order Ref 2] - table reference) and tells me what the next number in the sequence is.

Potential Issue:
Sometimes, an N/A gets put in one of these cells if a schedule has been cancelled, or placed on a credit card, so worried the moment a text value gets entered, it'll throw that formula out.

Any help would be greatly appreciated.
Thank you.
Regards
Marhier.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
It should be as simple as
Excel Formula:
=MAX(PurchaseOrderTable[Order Ref 2])+1
 
Upvote 0
Solution
Thanks Jason.
The issue I'm having with this solution is when someone put's an "N/A" in a cell from the order number column, it returns a #VALUE!

Any way to avoid this?

Much appreciated.
Thank you.
Regards
Marhier.
 
Upvote 0
There is no reason for that to happen, it works fine for me.
Book1
OPQ
4Order Ref 2
517
62
7N/A
84
95
106
Sheet14
Cell Formulas
RangeFormula
Q5Q5=MAX(Table1[Order Ref 2])+1
 
Upvote 0
That's strange.
See attached image - have I done something wrong?

Regards
Marhier.
 

Attachments

  • 01.png
    01.png
    84.1 KB · Views: 42
Upvote 0
The way I did it above, gives me the result I want, but fails when I put an "N/A"
The way you suggested, just displays a "1" and doesn't give me the correct result.

See attached:

To clarify, I'm on Excel (Office 365).
 

Attachments

  • 01.png
    01.png
    83.8 KB · Views: 22
Last edited:
Upvote 0
Then it means that your numbers are formatted as text. You need proper numbers for formulas to work.

Looking at your screen capture, you may also have a problem with the dates in columns H, J, and R. They might look fine but if they are in text format then formulas will not recognise them and it will be absolute carnage if you try to sort the table using one of those columns.
 
Upvote 0
Ah, you're right!
I think I did this becuase I wanted to keep the leading zeros, due to the last 4 digits of our order numbers being 4 characters.
I should have formatted to custom and then put 0000 in the type!

This is now working.

I can confirm all my other cells are formatted correctly, lol!

Thanks mate.
Regards
Marhier.
 
Upvote 0
I can confirm all my other cells are formatted correctly,
The giveaway is the alignment of the cells. Typically anything that uses a valid numeric format will be aligned to the right of the cell, text will be aligned to the left. While it is never a certainty because people do change the alignment, it is often a good indicator in a screen capture.

Glad you got it working, I had just started typing up a 'how to' guide to covert everything to valid numbers but as with many things, it's easier to do than to explain.
 
Upvote 0

Forum statistics

Threads
1,224,826
Messages
6,181,192
Members
453,021
Latest member
pingpong7117

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