Formula: Search for value in range, but equal to specific text

DarkSmile

Board Regular
Joined
Feb 22, 2021
Messages
90
Office Version
  1. 365
Platform
  1. Windows
Hello,

It's really hard to try to explain what I want (in my head it's so clear ? ) In a previous post I asked for a formula to search for the biggest value equal to cell B4.
Now I would like to do the following:

B13 has the output of the biggest value. I would like to search for that output in cell A21:B31 and tell me which category is equal to that value, but only look/search for the values equal to B4

Example: Here he can only choose between A, F & K to see wich one equals 12.
1614865706556.png


If multiple correct options just take it in alphabetic order.

TCA berekening.xlsm
AB
3Parameters : ISO 22000:2018
4Categorieën?: A, F, K,
5
6Aantal HACCP-plannen?:
7Aantal FTE's?:
8Extra site(s)?:
9N/A
10
11Haalt comma's wegA F K
12Grootste CAT
13Grootste CAT (uren)12
14
15
16
17
18
19
20CategorieënTe besteden mandagen (uren)
21A6
22B6
23C12
24D12
25E8
26F8
27G8
28H8
29I8
30J8
31K12
ISO22000
Cell Formulas
RangeFormula
A9A9=IF(B8="Ja",'ISO22000'!$F$36,"N/A")
B11B11=SUBSTITUTE(B4,",","")
B13B13=AGGREGATE(14,6,(SEARCH('ISO22000'!$A$21:$A$31,B4)>0)*('ISO22000'!$B$21:$B$31),1)
Named Ranges
NameRefers ToCells
ISOOutput='ISO22000'!$B$4B13, B11
Cells with Data Validation
CellAllowCriteria
B6List=HACCPISO22000
B7List=FTEISO22000
B8List=ExtraSiteISO
B9List=AantalSitesISO
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Excel Formula:
=INDEX(A21:A31,AGGREGATE(14,6,(SEARCH(A21:A31,B4)>0)*(B21:B31=B13)*ROW(A21:A31)-20,1))
 
Upvote 0
Doesn't seem to work.. lowered the cells in the mean time so here is an update, but I'm getting a #REF!
TCA berekening.xlsm
AB
3Parameters : ISO 22000:2018
4Categorieën?: A, F, K,
5
6Aantal HACCP-plannen?:2
7Aantal FTE's?:50-79
8Extra site(s)?:Ja
9Aantal extra site(s)?:
10
11Haalt comma's wegA F K
12Grootste CAT#REF!
13Grootste CAT (uren)12
14HACCP (uren)#N/A
15Aantal extra haccps2
16HACCP x aantal#N/A
17TMS2
18FTE8
19Totaal 1ste site#N/A
20Extra sites#N/A
21Totaal auditduur:#N/A
22Totaal auditduur (per extra site)#N/A
23
24
25CategorieënTe besteden mandagen (uren)
26A6
27B6
28C12
29D12
30E8
31F8
32G8
33H8
34I8
35J8
36K12
ISO22000
Cell Formulas
RangeFormula
A9A9=IF(B8="Ja",'ISO22000'!$F$41,"N/A")
B11B11=SUBSTITUTE(B4,",","")
B12B12=INDEX(A26:A36,AGGREGATE(14,6,(SEARCH(A26:A36,B4)>0)*(B26:B36=B13)*ROW(A26:A36)-20,1))
B13B13=AGGREGATE(14,6,(SEARCH('ISO22000'!$A$26:$A$36,B4)>0)*('ISO22000'!$B$26:$B$36),1)
B14B14=LOOKUP(1000,SEARCH($A$26:$A$36,B12),$C$26:$C$36)
B15B15=IF(B6>"2",B6-1,B6)
B16B16=IF(B15<"0",B14*B15,0)
B17B17=D26
B18B18=LOOKUP(1000,SEARCH($E$26:$E$36,B7),$F$26:$F$36)
B19B19=B13+B16+B17+B18
B20B20=IF(B8="Ja",B19/2,0)
B21:B22B21=B19
A22A22=IF(B8="Ja",F42,"N/A")
Named Ranges
NameRefers ToCells
ISOOutput='ISO22000'!$B$4B11:B13
Cells with Data Validation
CellAllowCriteria
B6List=HACCPISO22000
B7List=FTEISO22000
B8List=ExtraSiteISO
B9List=AantalSitesISO
 
Upvote 0
For more options repeat the formula and change the value for the nth position.
VBA Code:
=IFERROR(INDEX(A21:A31,AGGREGATE(15,6,(SEARCH(A21:A31,B4)>0)*(B21:B31=B13)*(ROW(A21:A31)-20),1)),"")&" "&IFERROR(INDEX(A21:A31,AGGREGATE(15,6,(SEARCH(A21:A31,B4)>0)*(B21:B31=B13)*ROW(A21:A31)-20,2)),"")&" "&IFERROR(INDEX(A21:A31,AGGREGATE(15,6,(SEARCH(A21:A31,B4)>0)*(B21:B31=B13)*ROW(A21:A31)-20,3)),"")
 
Upvote 0
It may be just me.. but this works but gives the wrong output..

TCA berekening.xlsm
AB
3Parameters : ISO 22000:2018
4Categorieën?: A, F, K,
5
6Aantal HACCP-plannen?:2
7Aantal FTE's?:50-79
8Extra site(s)?:Nee
9N/A
10
11Grootste CATJ
12Grootste CAT (uren)12
13HACCP (uren)2
14Aantal extra haccps2
15HACCP x aantal4
16TMS2
17FTE8
18Totaal 1ste site26
19Extra sites0
20Totaal auditduur:26
21N/A0
22
23
24CategorieënTe besteden mandagen (uren)
25A6
26B6
27C12
28D12
29E8
30F8
31G8
32H8
33I8
34J8
35K12
ISO22000
Cell Formulas
RangeFormula
A9A9=IF(B8="Ja",'ISO22000'!$F$40,"N/A")
B11B11=INDEX(A25:A35,AGGREGATE(14,6,(SEARCH(A25:A35,B4)>0)*(B25:B35=B12)*ROW(A25:A35)-25,1))
B12B12=AGGREGATE(14,6,(SEARCH('ISO22000'!$A$25:$A$35,B4)>0)*('ISO22000'!$B$25:$B$35),1)
B13B13=LOOKUP(1000,SEARCH($A$25:$A$35,B11),$C$25:$C$35)
B14B14=IF(B6>"2",B6-1,B6)
B15B15=IF(B14<"0",B13*B14,0)
B16B16=D25
B17B17=LOOKUP(1000,SEARCH($E$25:$E$35,B7),$F$25:$F$35)
B18B18=B12+B15+B16+B17
B19B19=IF(B8="Ja",B18/2,0)
B20:B21B20=B18
A21A21=IF(B8="Ja",F41,"N/A")
Named Ranges
NameRefers ToCells
ISOOutput='ISO22000'!$B$4B11:B12
Cells with Data Validation
CellAllowCriteria
B6List=HACCPISO22000
B7List=FTEISO22000
B8List=ExtraSiteISO
B9List=AantalSitesISO
 
Upvote 0
VBA Code:
=IFERROR(INDEX(A21:A31,AGGREGATE(15,6,(SEARCH(A21:A31,B4)>0)*(B21:B31=B13)*(ROW(A21:A31)-20),1)),"")&" "&IFERROR(INDEX(A21:A31,AGGREGATE(15,6,(SEARCH(A21:A31,B4)>0)*(B21:B31=B13)*ROW(A21:A31)-20,2)),"")&" "&IFERROR(INDEX(A21:A31,AGGREGATE(15,6,(SEARCH(A21:A31,B4)>0)*(B21:B31=B13)*ROW(A21:A31)-20,3)),"")

Shows all the things
1614869300259.png
 
Upvote 0
deleting a row --> ROW(A25:A35)-24 (first rownumber 25 - 24 = 1)
 
Upvote 0
changing rows --> A21:A31 ==> A25:A35
etc.
 
Upvote 0
I'm sorry, but I'm a basic excel user.. can't seem to figure this one out... here what I tried
Excel Formula:
=IFERROR(INDEX(A25:A35,AGGREGATE(15,6,(SEARCH(A25:A35,B4)>0)*(B25:B35=B12)*(ROW(A25:A35)-20),1)),"")&" "&IFERROR(INDEX(A25:A35,AGGREGATE(15,6,(SEARCH(A25:A35,B4)>0)*(B25:B35=B12)*ROW(A25:A35)-20,2)),"")&" "&IFERROR(INDEX(A25:A35,AGGREGATE(15,6,(SEARCH(A25:A35,B4)>0)*(B25:B35=B12)*ROW(A25:A35)-20,3))*ROW(A25:A35)-24,"")
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,243
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