Return Multiple Matches

Nanogirl21

Active Member
Joined
Nov 19, 2013
Messages
330
Office Version
  1. 365
Platform
  1. Windows
I hope everyone is going well and staying safe.

How can I use a formula to return all results that match the criteria? Some results will have multiple returns. I’d like those to show all results in 1 cell separated by a Char(10) returns.

Search criteria are in cell A2 and AC2 on Sheet 1 (The results must match both).
Data is on Sheet 2 Columns A-C. The formula would search Col. A and B returning Col. C
Results would be on Sheet 1 cell AC3

Example:
Sheet 1 Criteria A2: Manager
Sheet 1 Criteria AC2: 132A

Sheet 2 Data
COL A:COL B:COL: C
Manager132AJohn
Supervisor132CMike
Team132CJohnny
Manager132BTom
Manager132AChris

Expected Results Sheet 1 Cell AC3
John
Chris
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
What version of Excel are you using?

I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

I have Microsoft/Excel 2013.
 
Upvote 0
Thanks for updating your profile.
With 2013 you will be better of with a UDF rather than a formula, is that ok?
 
Upvote 0
Thanks for updating your profile.
With 2013 you will be better of with a UDF rather than a formula, is that ok?

Thank you. I plan to incorporate this into a larger sheet that I am using for reporting. It would be easier on my end with a formula. Also, multiple users and skill levels will be using this, so I'm not sure how that would work.
 
Upvote 0
With 365 or 2019, it would be simple to do it with a formula, but for 2013 it would be pretty horrendous, especially if you have a lot of data.
A UDF is used like a formula, but there is a macro in the background, so macros will need to be enabled for all users & it would only work in a desktop version.
 
Upvote 0
With 365 or 2019, it would be simple to do it with a formula, but for 2013 it would be pretty horrendous, especially if you have a lot of data.
A UDF is used like a formula, but there is a macro in the background, so macros will need to be enabled for all users & it would only work in a desktop version.

Okay. Thank you for explaining. Can you please help with the UDF version.
 
Upvote 0
Ok, put this in a standard module
VBA Code:
Function Nanogirl(Level As String, Dept As String, Data As Range) As String
   Dim Cl As Range
   For Each Cl In Data.Columns(1).Rows
      If Cl.Value = Level And Cl.Offset(, 1) = Dept Then
         Nanogirl = Nanogirl & vbLf & Cl.Offset(, 2).Value
      End If
   Next Cl
   Nanogirl = Mid(Nanogirl, 2)
End Function
And it's used like
+Fluff 1.xlsm
AABAC
1
2Manager132A
3John Chris
Sheet1
Cell Formulas
RangeFormula
AC3AC3=Nanogirl(A2,AC2,Sheet2!A2:C6)


+Fluff 1.xlsm
ABC
1LevelDeptName
2Manager132AJohn
3Supervisor132CMike
4Team132CJohnny
5Manager132BTom
6Manager132AChris
Sheet2
 
Upvote 0
Solution
Ok, put this in a standard module
VBA Code:
Function Nanogirl(Level As String, Dept As String, Data As Range) As String
   Dim Cl As Range
   For Each Cl In Data.Columns(1).Rows
      If Cl.Value = Level And Cl.Offset(, 1) = Dept Then
         Nanogirl = Nanogirl & vbLf & Cl.Offset(, 2).Value
      End If
   Next Cl
   Nanogirl = Mid(Nanogirl, 2)
End Function
And it's used like
+Fluff 1.xlsm
AABAC
1
2Manager132A
3John Chris
Sheet1
Cell Formulas
RangeFormula
AC3AC3=Nanogirl(A2,AC2,Sheet2!A2:C6)


+Fluff 1.xlsm
ABC
1LevelDeptName
2Manager132AJohn
3Supervisor132CMike
4Team132CJohnny
5Manager132BTom
6Manager132AChris
Sheet2

I am not getting any results. I followed your steps, but the AC3 where I entered the formula is blank.
 
Upvote 0
What is the name of the sheet & the range with the data?
Also did you put the code in a standard module in the same workbook with the data?
 
Upvote 0

Forum statistics

Threads
1,214,837
Messages
6,121,883
Members
449,057
Latest member
Moo4247

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