Search for 2 values and return 3rd

PixelNation

New Member
Joined
Sep 14, 2009
Messages
2
Hi there!

I'm trying to write a macro that will ask a user to input two values and search for a match for the first value in column A and the second value in column b (values must be in the same row).

If a match in both columns is found then I would like the macro to return the cell value of column c in the same row (eg msgbox "Match found: column c value")

If the search can only find 1 of the 2 values in the same row or there are no matches then I would like the macro to say something like "No Match Found".

Your help would be very, veery much appreciated!!!!!

Thanks in advance - Pixelnation :)
 
You don't really need a macro for this, a standard worksheet formula does the trick nicely.

Here's a sample layout of a three column data set and the formula that can bring in a 3rd column match off of the values you enter in the first two search cells.

Excel Workbook
ABCDEFG
1NamesColorsAnimalsNameColorAnimal
2BobredparrotSamredcat
3SambluebeetleBobblueparrot
4Bettybrownbear
5Debbiereddog
6Bobblueparrot
7Sambrowndog
8Bettyyellowcanary
9Debbieyellowdog
10Bobyellowcat
11Samredcat
12Bettybluefish
13Debbiebrowncat
Sheet2
 
Upvote 0
Hi! Thanks for your response!

I appreciate that a formula can do this but I want a user (who has no knowledge of excel) to be able to enter two values into a userform eg. a street number in field a (which will search column A) and a street name in field b (which will search column B) and the resulting message box will return a value which is located in column C next to the corresponding street number and street name.

I'm sure this is possible but with my basic knowledge of VBA unfortunately I don't know how to phrase it...
 
Upvote 0

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