VBA to paste data if two cells are the same

Excel43

New Member
Joined
Jan 7, 2020
Messages
14
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
  2. MacOS
Hi,

I have two sheets. In sheet B I got Name and Group at H2-I6 (blue image). In Sheet A I got Name and Group at A1-B5. What I would like to do is pasting the groups from sheet A to sheet B if the names are the same.

For example. If Eric is found in the H column, the cell next to Eric (column I) should say "A".

Note that the length of the list could be much longer (maybe 50-100 names) and not in order.

I would really appreciate if someone also could explain what the code does, as I am trying to learn.


a.PNG
B.PNG
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi & welcome to MrExcel.
How about, in I3 copied down
=IFERROR(VLOOKUP(H3,Sheet1!$A$2:$B$200,2,0),"")

change sheet name to suit
 
Upvote 0
Actually, this works great! Wow what a fast answear. Thank you
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,751
Messages
6,126,669
Members
449,326
Latest member
asp123

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