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?

[TABLE="width: 284"]
<tbody>[TR]
[TD]RTG_SP[/TD]
[TD]RTG_DBRS[/TD]
[TD]RTG_MOODY[/TD]
[TD]RTG_FITCH[/TD]
[/TR]
[TR]
[TD]AAA[/TD]
[TD]AAA[/TD]
[TD]Aaa[/TD]
[TD]AAA[/TD]
[/TR]
[TR]
[TD]AA+[/TD]
[TD]AAH[/TD]
[TD]Aa1[/TD]
[TD]AA+[/TD]
[/TR]
[TR]
[TD]AA[/TD]
[TD]AA[/TD]
[TD]Aa2[/TD]
[TD]AA[/TD]
[/TR]
[TR]
[TD]AA-[/TD]
[TD]AAL[/TD]
[TD]Aa3[/TD]
[TD]AA-[/TD]
[/TR]
[TR]
[TD]A+[/TD]
[TD]AH[/TD]
[TD]A1[/TD]
[TD]A+[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]A[/TD]
[TD]A2[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]A-[/TD]
[TD]AL[/TD]
[TD]A3[/TD]
[TD]A-[/TD]
[/TR]
[TR]
[TD]BBB+[/TD]
[TD]BBBH[/TD]
[TD]Baa1[/TD]
[TD]BBB+[/TD]
[/TR]
[TR]
[TD]BBB[/TD]
[TD]BBB[/TD]
[TD]Baa2[/TD]
[TD]BBB[/TD]
[/TR]
[TR]
[TD]BBB-[/TD]
[TD]BBBL[/TD]
[TD]Baa3[/TD]
[TD]BBB-[/TD]
[/TR]
[TR]
[TD]BB+[/TD]
[TD]BBH[/TD]
[TD]Ba1[/TD]
[TD]BB+[/TD]
[/TR]
[TR]
[TD]BB[/TD]
[TD]BB[/TD]
[TD]Ba2[/TD]
[TD]BB[/TD]
[/TR]
[TR]
[TD]BB-[/TD]
[TD]BBL[/TD]
[TD]Ba3[/TD]
[TD]BB-[/TD]
[/TR]
[TR]
[TD]B+[/TD]
[TD]BH[/TD]
[TD]B1[/TD]
[TD]B+[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]B[/TD]
[TD]B2[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]B-[/TD]
[TD]BL[/TD]
[TD]B3[/TD]
[TD]B-[/TD]
[/TR]
[TR]
[TD]CCC+[/TD]
[TD]CCCH[/TD]
[TD]Caa1[/TD]
[TD]CCC[/TD]
[/TR]
[TR]
[TD]CCC[/TD]
[TD]CCC[/TD]
[TD]Caa2[/TD]
[TD]CCC[/TD]
[/TR]
[TR]
[TD]CCC-[/TD]
[TD]CCCL[/TD]
[TD]Caa3[/TD]
[TD]CCC[/TD]
[/TR]
[TR]
[TD]CC[/TD]
[TD]CC[/TD]
[TD]Ca[/TD]
[TD]DDD[/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD]D[/TD]
[TD]C[/TD]
[TD]DD[/TD]
[/TR]
</tbody>[/TABLE]


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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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