Next available reference number

zefrogi

New Member
Joined
Feb 25, 2022
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hi, looking for a little help on how to improve my next available reference formula to include gaps.


The next available ref: AA007
RefHeading
AA001Test1
AA003Test2
AA004Test3
AA006Test4

At the moment I have code:
Excel Formula:
="The next available ref: AA"&SUM(AGGREGATE(14,6,NOT(ISBLANK(Table[Ref]))*RIGHT(Table[Ref],3)*1,1),1)

Which would read: AA007 - is there any way I can make it read AA002 without using VBA or a helper column?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
This should do it, subject to AA being the only prefix used. If you want the prefix to change when the reference number reaches 999 then that will require a different approach and may only be possible with vba.
Book1
A
1The next available ref: AA002
2Ref
3AA001
4AA003
5AA004
6AA006
Sheet2
Cell Formulas
RangeFormula
A1A1="The next available ref: AA"&TEXT(MATCH(TRUE,COUNTIF(Table[Ref],"AA"&TEXT(ROW(Table)-ROW(Table[#Headers]),"000"))=0,0),"000")
 
Upvote 0
Solution
This should do it, subject to AA being the only prefix used. If you want the prefix to change when the reference number reaches 999 then that will require a different approach and may only be possible with vba.
Book1
A
1The next available ref: AA002
2Ref
3AA001
4AA003
5AA004
6AA006
Sheet2
Cell Formulas
RangeFormula
A1A1="The next available ref: AA"&TEXT(MATCH(TRUE,COUNTIF(Table[Ref],"AA"&TEXT(ROW(Table)-ROW(Table[#Headers]),"000"))=0,0),"000")
Champion! Thank you.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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