Finding exact text string in an array

gcefaloni

Board Regular
Joined
Mar 15, 2016
Messages
119
Hi guys,

I have a question regarding the best way to find the row number of a cell containing an exact string which in my example is a single letter. The problem I'm encountering is that this letter also happens to be within words of other cells. How would I go about returning only the row with the exact letter as a text string. The following table should help understand the situation

I'm using the following formula to search the array below:

=INDEX(Credit_Ratings,SMALL(IF(NOT(ISERROR(SEARCH(J6,Credit_Ratings))),ROW($1:$22),99^99),1),2)

J6 cell contains only the letter "A". The problem is that this letter also happens to be within the string AAA, AA+, A+, etc. However, I want the formula to return row number 7, not row number 2 because it finds an "A" within the "AAA" string in row 2. How would I go about modifying the above formula to return only the row for the exact content of cell J6 and nothing else?

RTG_SPRTG_DBRSRTG_MOODYRTG_FITCH
AAAAAAAaaAAA
AA+AAHAa1AA+
AAAAAa2AA
AA-AALAa3AA-
A+AHA1A+
AAA2A
A-ALA3A-
BBB+BBBHBaa1BBB+
BBBBBBBaa2BBB
BBB-BBBLBaa3BBB-
BB+BBHBa1BB+
BBBBBa2BB
BB-BBLBa3BB-
B+BHB1B+
BBB2B
B-BLB3B-
CCC+CCCHCaa1CCC
CCCCCCCaa2CCC
CCC-CCCLCaa3CCC
CCCCCaDDD
DDCDD

<tbody>
</tbody>


Thank you very much in advance!

P.S. =SUMPRODUCT((Credit_Ratings=J6)*(ROW(Credit_Ratings))) is a different way to go about it, but I encounter the same type of problem.
 
Last edited:

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.
Aha, got it. You could also use something simple (no array formula) like:

Code:
=MIN(IFERROR(MATCH(J6,$A$2:$A$22,0),999),IFERROR(MATCH(J6,$B$2:$B$22,0),999),IFERROR(MATCH(J6,$C$2:$C$22,0),999),IFERROR(MATCH(J6,$D$2:$D$22,0),999))
 
Upvote 0

Book1
ABCDJ
1RTG_SPRTG_DBRSRTG_MOODYRTG_FITCH
2AAAAAAAaaAAA
3AA+AAHAa1AA+
4AAAAAa2AA
5AA-AALAa3AA-
6A+AHA1A+A
7AAA2A7
8A-ALA3A-
9BBB+BBBHBaa1BBB+
10BBBBBBBaa2BBB
11BBB-BBBLBaa3BBB-
12BB+BBHBa1BB+
13BBBBBa2BB
14BB-BBLBa3BB-
15B+BHB1B+
16BBB2B
17B-BLB3B-
18CCC+CCCHCaa1CCC
19CCCCCCCaa2CCC
20CCC-CCCLCaa3CCC
21CCCCCaDDD
22DDCDD
Sheet1


In J7 control+shift+enter, not just enter:

=MIN(IF(MMULT(ISNUMBER(SEARCH(" "&J6&" "," "&$A$2:$D$22&" "))+0,TRANSPOSE(COLUMN($A$2:$D$22)^0)),ROW($A$2:$D$22)))
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,269
Members
449,075
Latest member
staticfluids

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