Lookup multiple criteria

dangerousdaveeg

New Member
Joined
Mar 30, 2012
Messages
8
Office Version
  1. 2013
Platform
  1. Windows
Hello

I have looked online and tried multiple different suggestions but I must be doing something wrong as I cant get the desired result.

What I want to do is.

In cell A60 is a Data validation list derived from all of the names in cells A2:A55
In cell A61 I wanted a formula to look for the name from A60 within the range A2:A55 and then look for any instance of the number 1 within range B2:AE55 and for every match of the number 1 I wanted to return the dates they relate to that is in range B1:AE1

Below is a screenshot of the data that hopefully helps with what I want to achieve, So as an example I would want the end result to show 5/2/2022 & 26/2/2022

Capture1.JPG


Thanks

Dave
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Could you update Excel version in your profile, please? It helps to find out a solution.
 
Upvote 0
Are the Agents in A2 to A55 unique or may one Agent appear multiple times?
 
Upvote 0
Mini sheet below

Example.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAE
1Name05/02/202212/02/202219/02/202226/02/202205/03/202212/03/202219/03/202226/03/202202/04/202209/04/202216/04/202223/04/202230/04/202207/05/202214/05/202221/05/202228/05/202204/06/202211/06/202218/06/202225/06/202202/07/202209/07/202216/07/202223/07/202230/07/202206/08/202213/08/202220/08/202227/08/2022
2Agent 111111
3Agent 2111
4Agent 3111
5Agent 4111
6Agent 5111
7Agent 61111
8Agent 71111
9Agent 81111
10Agent 91111
11Agent 101111
12Agent 111111
13Agent 121111
14Agent 131111
15Agent 141111
16Agent 151111
17Agent 161111
18Agent 17111
19Agent 181111
20Agent 19111
21Agent 201111
22Agent 211111
23Agent 221111
24Agent 231111
25Agent 24111
26Agent 251111
27Agent 261111
28Agent 271111
29Agent 281111
30Agent 291111
31Agent 301111
32Agent 311111
33Agent 321111
34Agent 331111
35Agent 341111
36Agent 351111
37Agent 361111
38Agent 371111
39Agent 381111
40Agent 391111
41Agent 4011
42Agent 411111
43Agent 421111
44Agent 431111
45Agent 441111
46Agent 451111
47Agent 461111
48Agent 471111
49Agent 481111
50Agent 491111
51Agent 501111
52Agent 511111
53Agent 521111
54Agent 531111
55Agent 541111
56
57
58
59
60Agent 1
Sheet1
Cells with Data Validation
CellAllowCriteria
A60List=$A$2:$A$55
 
Upvote 0
Does this work?

DangerousDaveeg.xlsx
ABC
59Select AgentDates
60Agent 105-Feb-22
6126-Feb-22
62 
63 
Sheet1
Cell Formulas
RangeFormula
C60:C63C60=IFERROR(INDEX($B$1:$AE$1,AGGREGATE(15,6,COLUMN($B$1:$AE$1)-COLUMN($A$1)/((INDEX($B$2:$AE$55,MATCH($A$60,$A$2:$A$55,0),(COLUMN($B$1:$AE$1)-COLUMN($B$1)))=1)),ROW()-ROW($C$59))),"")
Cells with Data Validation
CellAllowCriteria
A60List=$A$2:$A$55
 
Upvote 0
Solution
Book1
ABCDEFGHI
1Name05/02/202212/02/202219/02/202226/02/202205/03/202212/03/202219/03/202226/03/2022
2Agent 111
3Agent 2
4Agent 3
5Agent 4
6Agent 5
7Agent 61
8Agent 71
9Agent 81
10Agent 911
11Agent 1011
59
60Agent 105/02/2022 26/02/2022 28/05/2022 02/07/2022 30/07/2022
Sheet1
Cell Formulas
RangeFormula
B60B60=textjoinSUB(TEXT(IF(OFFSET($A$2:$A$55,MATCH($A$60,$A$2:$A$55,0)-1,1,1,COLUMNS($B$2:$AE$2))=1,$B$1:$AE$1,""),"dd/mm/yyyy")," ",0)
Press CTRL+SHIFT+ENTER to enter array formulas.


As on XL2013 there is no TEXTJOIN I've used UDF as substitute (to get result as you want to in format date & date)

VBA Code:
Public Function textjoinSUB(ByVal varData As Variant, Optional ByVal sDelimiter As String = vbNullString, Optional ByVal bUnique As Boolean = False) As String
'Created by TigerAvatar at www.excelforum.com, September 2012
'Purpose is to concatenate many strings into a single string
'Can be used with arrays, range objects, and collections
  
    Dim DataIndex As Variant    'Used to loop through arrays, range objects, and collections
    Dim strResult As String     'Used to build the result string
  
    'Test if varData is an Array, Range, or Collection
    If IsArray(varData) _
    Or TypeOf varData Is Range _
    Or TypeOf varData Is Collection Then
      
        'Found to be an, array, range object, or collection
        'Loop through each item in varData
        For Each DataIndex In varData
            'Check if the item isn't empty
            If Len(DataIndex) > 0 Then
                'Found the item isn't empty, check if user specified bUnique as True
                If bUnique = True Then
                    'bUnique is true, check if the item has been included in the result yet
                    If InStr(1, "||" & strResult & "||", "||" & DataIndex & "||", vbTextCompare) = 0 Then
                        'Item has not been included in the result, add item to the result
                        strResult = strResult & "||" & DataIndex
                    End If
                Else
                    'bUnique is not true, add item to the result
                    strResult = strResult & "||" & DataIndex
                End If
            End If
        Next DataIndex
      
        'Correct strResult to remove beginning delimiter and convert "||" to the specified sDelimiter
        strResult = Replace(Mid(strResult, 3), "||", sDelimiter)
      
    Else
        'Found not to be an array, range object, or collection
        'Simply set the result = varData
        strResult = varData
    End If
  
    'Output result
    textjoinSUB = strResult
  
End Function
 
Upvote 0
H
Does this work?

DangerousDaveeg.xlsx
ABC
59Select AgentDates
60Agent 105-Feb-22
6126-Feb-22
62 
63 
Sheet1
Cell Formulas
RangeFormula
C60:C63C60=IFERROR(INDEX($B$1:$AE$1,AGGREGATE(15,6,COLUMN($B$1:$AE$1)-COLUMN($A$1)/((INDEX($B$2:$AE$55,MATCH($A$60,$A$2:$A$55,0),(COLUMN($B$1:$AE$1)-COLUMN($B$1)))=1)),ROW()-ROW($C$59))),"")
Cells with Data Validation
CellAllowCriteria
A60List=$A$2:$A$55

This works exactly as required, I now just need to tweak it as it has come to light that some users are only going to use it in google sheets and that does not support the Aggregate function, unfortunately.

Thanks for the help
 
Upvote 0
Book1
ABCDEFGHI
1Name05/02/202212/02/202219/02/202226/02/202205/03/202212/03/202219/03/202226/03/2022
2Agent 111
3Agent 2
4Agent 3
5Agent 4
6Agent 5
7Agent 61
8Agent 71
9Agent 81
10Agent 911
11Agent 1011
59
60Agent 105/02/2022 26/02/2022 28/05/2022 02/07/2022 30/07/2022
Sheet1
Cell Formulas
RangeFormula
B60B60=textjoinSUB(TEXT(IF(OFFSET($A$2:$A$55,MATCH($A$60,$A$2:$A$55,0)-1,1,1,COLUMNS($B$2:$AE$2))=1,$B$1:$AE$1,""),"dd/mm/yyyy")," ",0)
Press CTRL+SHIFT+ENTER to enter array formulas.


As on XL2013 there is no TEXTJOIN I've used UDF as substitute (to get result as you want to in format date & date)

VBA Code:
Public Function textjoinSUB(ByVal varData As Variant, Optional ByVal sDelimiter As String = vbNullString, Optional ByVal bUnique As Boolean = False) As String
'Created by TigerAvatar at www.excelforum.com, September 2012
'Purpose is to concatenate many strings into a single string
'Can be used with arrays, range objects, and collections
 
    Dim DataIndex As Variant    'Used to loop through arrays, range objects, and collections
    Dim strResult As String     'Used to build the result string
 
    'Test if varData is an Array, Range, or Collection
    If IsArray(varData) _
    Or TypeOf varData Is Range _
    Or TypeOf varData Is Collection Then
     
        'Found to be an, array, range object, or collection
        'Loop through each item in varData
        For Each DataIndex In varData
            'Check if the item isn't empty
            If Len(DataIndex) > 0 Then
                'Found the item isn't empty, check if user specified bUnique as True
                If bUnique = True Then
                    'bUnique is true, check if the item has been included in the result yet
                    If InStr(1, "||" & strResult & "||", "||" & DataIndex & "||", vbTextCompare) = 0 Then
                        'Item has not been included in the result, add item to the result
                        strResult = strResult & "||" & DataIndex
                    End If
                Else
                    'bUnique is not true, add item to the result
                    strResult = strResult & "||" & DataIndex
                End If
            End If
        Next DataIndex
     
        'Correct strResult to remove beginning delimiter and convert "||" to the specified sDelimiter
        strResult = Replace(Mid(strResult, 3), "||", sDelimiter)
     
    Else
        'Found not to be an array, range object, or collection
        'Simply set the result = varData
        strResult = varData
    End If
 
    'Output result
    textjoinSUB = strResult
 
End Function
Thank you for your help, A formula based solution has been provided and I think for this scenario that may be the best option, but once again thank you for your time on this :)
 
Upvote 0

Forum statistics

Threads
1,215,375
Messages
6,124,578
Members
449,174
Latest member
chandan4057

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