using the find command across multiple columns

Danny54

Active Member
Joined
Jul 3, 2019
Messages
295
Office Version
  1. 365
Platform
  1. Windows
Good Morning all;

I've been trying to create a solution that would do a lookup across multiple columns between to excel worksheets I have two sheets as listed here, where the data in sheet1 (column A) is looked up in sheet2 (column B and column C). If found by scanning data found in these columns(can be anywhere in the column), the value from (column A Sheet2) is returned to Sheet1 column B

any help would be appreciated greatly.

Thanks



Sheet1
ServerReturn Value
Tom1
Tom2
Sally1
John3

Sheet2
UserServer1Server2
-Margret
Guest39JohnTom2
Guest40John3
Master1Fred1Mr. John3


Sheet1 after successfully running lookup vba code
ServerReturn Value
Tom1
Tom2Guest39
Sally1
John3Master1
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
trying to move forward with a solution, I inserted a helper column to be a new column A of sheet2 and filled it with =B1&" "&C1. this concatenated my search data into one cell
I then inserted =VLOOKUP("*"&A1&"*",Sheet2!A:B,2,FALSE) and copied down. This returned one of the matches, but not all. Do i need a array formula here in order to get all the columns found to be in one row?
 
Upvote 0
Hi,

In Sheet 2, you have "John3" in Both B & C columns, your expected result shows Master1, why? and why not Guest40?
 
Upvote 0
my bad, when scanning column B for John3 it would return Guest40 then when scanning for John3 in column C, a match would be made as well for Master1 since the string "Mr. John3" contains the string John3.

Net effect, for John3 in sheet1 after completion would say Guest40 Master1
 
Upvote 0
This would give you your desired results.
Since you have 365, there may be functions available for a simpler formula, I don't have 365:

Book1
AB
1ServerReturn Value
2Tom1 
3Tom2Guest39
4Sally1 
5John3Guest40 Master1
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=TRIM(IFERROR(LOOKUP(2,1/SEARCH(" "&A2&" "," "&Sheet2!B$2:B$10&" "),Sheet2!A$2:A$10),"")&" "&IFERROR(LOOKUP(2,1/SEARCH(" "&A2&" "," "&Sheet2!C$2:C$10&" "),Sheet2!A$2:A$10),""))


Book1
ABC
1UserServer1Server2
2-Margret
3Guest39JohnTom2
4Guest40John3
5Master1Fred1Mr. John3
6
7
8
9
10
Sheet2
 
Upvote 0
Solution
Thanks,
let me give this a shot.

Have a great weekend
 
Upvote 0
Thanks so much. This solution worked and was much easier than I thought. I was thinking it would be much harder than it really needed to be.
 
Upvote 0
You're welcome, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,500
Members
449,090
Latest member
RandomExceller01

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