VBA Lookup One Value To Copy and Paste Multiple Values

chriseponymous

New Member
Joined
Sep 24, 2023
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Hi Kind People,

I hope you are well.

I am on the scrounge for some assistance if possible. I need a VBA that works as a Lookup, unfortunately my knowledge is very limited.

I have information in two columns, for argument's sake A5:A30 and B5:B30. The first has a name of a site, the second contains the email address' of people who work there, the name of the site may be repeated numerous times.

When the name of the site is inputed into cell A1 I need the VBA to automatically find and paste the relevant email address' in a range, say C5:C30 Thank you very much for your assistance!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
This may work for you. If your version does not handle the dynamic arrays, hit Ctrl-Shift-Enter when done editing the formula and it should work.
Book1
ABC
1BD COMPANY
2
3
4
5BD COMPANYbob@bd.combob@bd.com
6ABC COMPANYjim@abc.com
7ABC COMPANYjoe@abc.com
8BD COMPANYjack@bd.comjack@bd.com
9ABC COMPANYjohn@abc.com
10BD COMPANYbuck@bd.combuck@bd.com
11BD COMPANYginny@bd.comginny@bd.com
12BD COMPANYmelissa@bd.commelissa@bd.com
13BD COMPANYkelly@bd.comkelly@bd.com
14ABC COMPANYpat@abc.com
15ABC COMPANYtammy@abc.com
16ABC COMPANYtommy@abc.com
17BD COMPANYjeremiah@bd.comjeremiah@bd.com
18BD COMPANYbecky@bd.combecky@bd.com
19BD COMPANYbobby@bd.combobby@bd.com
20BD COMPANYjeff@bd.comjeff@bd.com
21ABC COMPANYbryan@abc.com
22ABC COMPANYpaul@abc.com
23ABC COMPANYjackie@abc.com
24ABC COMPANYjerry@abc.com
25ABC COMPANYbryce@abc.com
26ABC COMPANYtaylor@abc.com
27ABC COMPANYaustin@abc.com
28ABC COMPANYedward@abc.com
29ABC COMPANYashlyn@abc.com
30BD COMPANYjewel@bd.comjewel@bd.com
Sheet3
Cell Formulas
RangeFormula
C5:C30C5=IF(A5:A30=$A$1,B5:B30,"")
Dynamic array formulas.

Hope that helps,

Doug
 
Upvote 0
Solution
This may work for you. If your version does not handle the dynamic arrays, hit Ctrl-Shift-Enter when done editing the formula and it should work.
Book1
ABC
1BD COMPANY
2
3
4
5BD COMPANYbob@bd.combob@bd.com
6ABC COMPANYjim@abc.com
7ABC COMPANYjoe@abc.com
8BD COMPANYjack@bd.comjack@bd.com
9ABC COMPANYjohn@abc.com
10BD COMPANYbuck@bd.combuck@bd.com
11BD COMPANYginny@bd.comginny@bd.com
12BD COMPANYmelissa@bd.commelissa@bd.com
13BD COMPANYkelly@bd.comkelly@bd.com
14ABC COMPANYpat@abc.com
15ABC COMPANYtammy@abc.com
16ABC COMPANYtommy@abc.com
17BD COMPANYjeremiah@bd.comjeremiah@bd.com
18BD COMPANYbecky@bd.combecky@bd.com
19BD COMPANYbobby@bd.combobby@bd.com
20BD COMPANYjeff@bd.comjeff@bd.com
21ABC COMPANYbryan@abc.com
22ABC COMPANYpaul@abc.com
23ABC COMPANYjackie@abc.com
24ABC COMPANYjerry@abc.com
25ABC COMPANYbryce@abc.com
26ABC COMPANYtaylor@abc.com
27ABC COMPANYaustin@abc.com
28ABC COMPANYedward@abc.com
29ABC COMPANYashlyn@abc.com
30BD COMPANYjewel@bd.comjewel@bd.com
Sheet3
Cell Formulas
RangeFormula
C5:C30C5=IF(A5:A30=$A$1,B5:B30,"")
Dynamic array formulas.

Hope that helps,

Doug
Hi Doug, Thank you very much for the solution and for the effort you put into the answer, I shall be giving this a try a bit later today! Just a quick question, if it's not too much, say I have further similar information in columns C and D, could these be added into the equation. Obviously the result will have to go in column E. Thank you!
 
Upvote 0
Thank you again. Just one last question... when the results are returned there are some rows in the column which have no value. Is there anyway to remove the gaps and have results displayed in sequential rows? Thank you.
 
Upvote 0

Forum statistics

Threads
1,215,100
Messages
6,123,086
Members
449,095
Latest member
gwguy

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