Find maximum number pith alpha prefix

KBBersch

New Member
Joined
May 31, 2017
Messages
3
I have a column that contains asset numbers in the form of PDL-xxxx and PTF-xxxx. I need to display the maximum number for each prefix, or better yet the next available number for each prefix. More entries will be added and the cells need to update as that happens. I tried =INDEX($B$6:$B$1001,MAXA(IF((LEFT($B$6:$B$1001)="PTF"),$B$6:$B$1001))) but that always returns the first entry in the column. I know I'm missing something but I'm not sure where to go from here. Any help is appreciated.

Thanks,
Kelly Bersch
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Welcome to Mr Excel

To get the next available try this array formula
="PTF-"&1+MAX(IF((LEFT($B$6:$B$1001,3)="PTF"),--RIGHT($B$6:$B$1001,4)))
Ctrl+Shift+Enter

Hope this helps

M.
 
Upvote 0
Welcome to Mr Excel

To get the next available try this array formula
="PTF-"&TEXT(1+MAX(IF((LEFT($B$6:$B$1001,3)="PTF"),--RIGHT($B$6:$B$1001,4))),"0000")
Ctrl+Shift+Enter
It looks to me like the OP would want a 4-digit number after the letters (hence, the red additions above). Also, I don't think you need the absolute references as this appears to be a formula that will only be placed in a single cell.
 
Last edited:
Upvote 0
This formula seems to also work...

=TEXT(1+IF(LEFT(B6:B1001,3)="PTF",RIGHT(B6:B1001,4)),"PTF0000")
 
Upvote 0
Thanks for both replies. I would appreciate a discussion of WHY the you chose the particular formula so I can maybe not have to ask as many questions.

Thanks.
 
Upvote 0
Thanks for both replies. I would appreciate a discussion of WHY the you chose the particular formula so I can maybe not have to ask as many questions.

Thanks.

Try something like this

B
C
D
E
5
Code​
Prefix​
Next Available​
6
PTF-0001​
PDL​
PDL-0005​
7
PDL-0001​
PTF​
PTF-0006​
8
PTF-0002​
9
PTF-0003​
10
PTF-0004​
11
PDL-0002​
12
PDL-0003​
13
PDL-0004​
14
PTF-0005​
15

Array formula in E6 copied down
=TEXT(1+MAX(IF(LEFT(B$6:B$1001,3)=D6,--RIGHT(B$6:B$1001,4))),CHAR(34)&D6&CHAR(34)&"-0000")
Ctrl+Shift+Enter

M.
 
Upvote 0
Array formula in E6 copied down
=TEXT(1+MAX(IF(LEFT(B$6:B$1001,3)=D6,--RIGHT(B$6:B$1001,4))),CHAR(34)&D6&CHAR(34)&"-0000")
Ctrl+Shift+Enter
If you put the 1+ inside the MAX function call, then you can eliminate the double minus in front of the RIGHT function call as doing that would involve the RIGHT function in a mathematical operation the same as the double negative did...

=TEXT(MAX(1+IF(LEFT(B$6:B$1001,3)=D6,RIGHT(B$6:B$1001,4))),CHAR(34)&D6&CHAR(34)&"-0000")

And then, if you want to save 9 characters, you can use proper quoting in place of the CHAR(34) calls...

=TEXT(MAX(1+IF(LEFT(B$6:B$1001,3)=D6,RIGHT(B$6:B$1001,4))),""""&D6&"""-0000")
 
Upvote 0

Forum statistics

Threads
1,215,062
Messages
6,122,923
Members
449,094
Latest member
teemeren

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