Finding multiple matches in long rows

GLIBBY

New Member
Joined
Jun 14, 2010
Messages
37
Im trying to create an excel file in which I need to find the locations of values that fit criteria in each column of a long (100+ column) row. I also need to repeat this process row by row. I was trying to use a cell based function, since I want the spreadsheet to work as the user changes values, instead of having to re-run a macro.

However, I cant come up with anything that seems to work. It seems like I'll either have to write a macro, or use a solution that would end up with an array function as big as the data itself.

The ideal solution would be if an arbitrary cell (x) could contain the location of the first match, then x+1 could contain the second location, etc... for as many matches as there are. Im not entirely sure this is feasible however.

Any suggestions?

Thanks.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Im trying to create an excel file in which I need to find the locations of values that fit criteria in each column of a long (100+ column) row. I also need to repeat this process row by row. I was trying to use a cell based function, since I want the spreadsheet to work as the user changes values, instead of having to re-run a macro.

However, I cant come up with anything that seems to work. It seems like I'll either have to write a macro, or use a solution that would end up with an array function as big as the data itself.

The ideal solution would be if an arbitrary cell (x) could contain the location of the first match, then x+1 could contain the second location, etc... for as many matches as there are. Im not entirely sure this is feasible however.

Any suggestions?

Thanks.
Need more specific details.
 
Upvote 0
Marcelo, thank you for the link. Its almost what I need but its hampered by the limited ability of the V and Hlookup functions. Heres a (hopefully) better explanation.


I have long rows of data, say:

a b c d e f g h i j k
1 2 3 4 5 6 5 7 8 9
1 2 5 5 3 4 6 7 8 9


For each row I want to find the column number of every instance of a specific value (say 5) in that row. I day dreamed that I could possibly have a duplicate number of cells, the same size as the data and check each cell individually, however that would be a very in-efficient method.

The problem with Hlookup is that there a multiple instances (solved by the above macro) and also the fact that the rows Im searching through are not always going to be the first row in the list.

I was hoping I could find some method to return the column of the Nth match to a specific value. Then I could have a small number off cells to the right of the data, that would display the column of the Nth match, if it existed. Since I dont anticipate a condition where every column of data would be a match, I think this would work.
 
Upvote 0
Marcelo, thank you for the link. Its almost what I need but its hampered by the limited ability of the V and Hlookup functions. Heres a (hopefully) better explanation.


I have long rows of data, say:

a b c d e f g h i j k
1 2 3 4 5 6 5 7 8 9
1 2 5 5 3 4 6 7 8 9


For each row I want to find the column number of every instance of a specific value (say 5) in that row. I day dreamed that I could possibly have a duplicate number of cells, the same size as the data and check each cell individually, however that would be a very in-efficient method.

The problem with Hlookup is that there a multiple instances (solved by the above macro) and also the fact that the rows Im searching through are not always going to be the first row in the list.

I was hoping I could find some method to return the column of the Nth match to a specific value. Then I could have a small number off cells to the right of the data, that would display the column of the Nth match, if it existed. Since I dont anticipate a condition where every column of data would be a match, I think this would work.
Try this...

Book1
ABCDEFGHIJKLMN
1__________LookupCountColumns_
212345657895257
31255346789_234
Sheet1

K2 = lookup value

Enter this formula in L2 and copy down as needed:

=COUNTIF(A2:J2,K$2)

This will return the count of lookup values per row.

Enter this array formula** in M2:

=IF(COLUMNS($M2:M2)>$L2,"",SMALL(IF($A2:$J2=$K$2,COLUMN($A2:$J2)),COLUMNS($M2:M2)))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

This will return the absolute column numbers of cells that contain the lookup value.

Copy down as needed then across until you get a full column of blanks.
 
Upvote 0

Forum statistics

Threads
1,224,593
Messages
6,179,791
Members
452,942
Latest member
VijayNewtoExcel

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