Finding 1st and last occurrence

michaelsmith559

Well-known Member
Joined
Oct 6, 2013
Messages
881
Office Version
  1. 2013
  2. 2007
I am trying to find a formula/code that will find the 1st and last occurrence of the 2nd value. Needs to be easily changed for 3rd, 4th, 5th values as well. Below is what I am looking to accomplish. The formulas should be able to be copied down. The values it will be looking for in the 2nd position will be from 2 to 67. Thanks for any help.

mm combinations.xlsm
XYZAAAB
111, 2, 3, 4, 5ValueStart RowEnd Row
2501161, 2, 68, 69, 702150116
3501171, 3, 4, 5, 635011798021
4980211, 3, 68, 69, 70
Sheet2
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
please update your profile button to show what version of Excel you are using?
 
Upvote 0
will the look for numbers ever repeat in the same cell?
 
Upvote 0
okay. can there be helper columns? With 2013 there is no way I know of that can treat the contents of a cell like an array.
It can be done with VBA probably, but I am not experienced in that.
 
Upvote 0
Here is a link where I used sumproduct for the 1 digit. I've tried adjusting it to count the 2nd digit but it gives wrong results.

 
Upvote 0
i'm not sure sumproduct works on values separated by commas to treat them as numeric. Can you use helper columns?
 
Upvote 0
How about in AA2
Excel Formula:
=INDEX(X:X,AGGREGATE(15,6,ROW($X$1:$X$4)/(REPLACE(MID($Y$1:$Y$4,1,FIND(",",$Y$1:$Y$4,4)-1),1,FIND(" ",$Y$1:$Y$4),"")=Z2&""),1))
and in AB2
Excel Formula:
=INDEX(X:X,AGGREGATE(14,6,ROW($X$1:$X$4)/(REPLACE(MID($Y$1:$Y$4,1,FIND(",",$Y$1:$Y$4,4)-1),1,FIND(" ",$Y$1:$Y$4),"")=Z2&""),1))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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