VBA for VlookUp copy and paste

rxpotlu

New Member
Joined
May 2, 2022
Messages
9
Office Version
  1. 2010
Team - Could you please help me with below?
i am looking for vba - to take cell c3 from sheet2 search for column a in sheet1 if a match is found then copy the value from b column which is next to the match cell in a to a specific cell in sheet2.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Welcome to the Board!

You are looking up the value from cell C3 on sheet 2, but where are you placing this value you find on sheet 2?
 
Upvote 0
axd1search a in column A, if a match then copy whats in column b (in this case x) to a specific column in sheet 2
bye1
czw1
dx2r1
 
Upvote 0
But what is the "specific column"?
If you want us to help you come up with the VBA code you need, we need details, not generalities.

So, look up the value from C3 and paste the result of the lookup to where? Cell D3 maybe?
And are we just doing this one cell, or a whole range of cells?
If a range, what exactly is that range?
 
Upvote 0
lemme retry this.
1ABCDEFGH
2Currencybankbank namecurrencyaud
3audabcabc 123bank
4cadxyzxyz 567bank name
5usdrrrrrr 444

if h2 is in column a then copy value in b and c to h3 and h4. so for example. h2 here is aud, so abc should be pasted in h3 and abc 123 in h4.
 
Upvote 0
Assuming that G and H are on Sheet2 and columns A, B, and C are on Sheet1 (like you said in your original question), try this code:
VBA Code:
Sub MyMacro()

'   Populate lookup formulas
    Range("H3").FormulaR1C1 = "=VLOOKUP(R[-1]C,Sheet1!C[-7]:C[-6],2,0)"
    Range("H4").FormulaR1C1 = "=VLOOKUP(R[-2]C,Sheet1!C[-7]:C[-5],3,0)"
    
'   Convert to hard-coded values
    Range("H3:H4").Value = Range("H3:H4").Value
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,731
Messages
6,126,537
Members
449,316
Latest member
sravya

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