Scan column for next available number

rplohocky

Active Member
Joined
Sep 25, 2005
Messages
292
Office Version
  1. 365
Platform
  1. Windows
Hello,
I have a column full of titles that look like this:
Ped 3081 CAB 3
Ped 3082 CAB 3
Ped 3083 CAB 3
Ped 3084 CAB 3
Ped 3085 CAB 3
PED 3086 CAB 3
PED 3104 CAB 4
PED 3105 CAB 4
PED 3106 CAB 4
PED 3107 CAB 4
PED 3108 CAB 4
PED 3109 CAB 4
PED 3110 CAB 4
I am looking for a formula that will search through column A looking for a specific set of words such as "CAB 3" or "CAB 4" then look at the number just after the word "PED" and provide the next available number i can use to name the next "PED". So if, in this case, "PED 3110 CAB 4" the formula would only look in the "CAB 4" 's and return the next available number which would be "3111". I can create a separate cell for each search if need be. I started with this but it does not work:
=IF(ISNUMBER(SEARCH("CAB 3",A:A)),IFERROR(INDEX(ROW(INDIRECT(MIN(A:A)&":"&MAX(A:A))),MATCH(0,INDEX(COUNTIF(A:A,ROW(INDIRECT(MIN(A:A)&":"&MAX(A:A)))),),0)),MAX(A:A)+1),"")

Thanks in advance!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
This looks like it works.
Book1
ABC
2Ped 3081 CAB 3CAB 4
3Ped 3082 CAB 33111
4Ped 3083 CAB 3
5Ped 3084 CAB 3
6Ped 3085 CAB 3
7PED 3086 CAB 3
8PED 3104 CAB 4
9PED 3105 CAB 4
10PED 3106 CAB 4
11PED 3107 CAB 4
12PED 3108 CAB 4
13PED 3109 CAB 4
14PED 3110 CAB 4
Sheet1
Cell Formulas
RangeFormula
C3C3=LET(l,--MID(FILTER(A2:A14,ISNUMBER(SEARCH(C2,A2:A14)),""),5,4),s,SEQUENCE(MAX(l)-MIN(l)+2,,MIN(l)),MIN(IF(ISNA(MATCH(s,l,0)),s)))
 
Upvote 0
What version of Excel are you using?

I suggest that you 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’)
 
Upvote 0
This looks like it works.
Book1
ABC
2Ped 3081 CAB 3CAB 4
3Ped 3082 CAB 33111
4Ped 3083 CAB 3
5Ped 3084 CAB 3
6Ped 3085 CAB 3
7PED 3086 CAB 3
8PED 3104 CAB 4
9PED 3105 CAB 4
10PED 3106 CAB 4
11PED 3107 CAB 4
12PED 3108 CAB 4
13PED 3109 CAB 4
14PED 3110 CAB 4
Sheet1
Cell Formulas
RangeFormula
C3C3=LET(l,--MID(FILTER(A2:A14,ISNUMBER(SEARCH(C2,A2:A14)),""),5,4),s,SEQUENCE(MAX(l)-MIN(l)+2,,MIN(l)),MIN(IF(ISNA(MATCH(s,l,0)),s)))
Thank you jasonb75! It work exactly like I want it too! It will save me a lot of time and guessing! I also updated my version of Excel since it was from 2005.
 
Upvote 0

Forum statistics

Threads
1,215,730
Messages
6,126,529
Members
449,316
Latest member
sravya

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