V lookup Code

vinothsudar

Board Regular
Joined
Jun 10, 2009
Messages
171
Hello friends,

Good Day.

I am Looking for Simple VBA Code for V look up.

Sheet 1


Excel Workbook
ABCD
5NameAmountcreditDebit
6Ravi
7Suresh
8Kannan
Sheet1


Compare with Sheet 2:


Excel Workbook
DEFG
1NameAmountcreditDebit
2Ravi200100100
3Kann500100400
4Sures800200600
5Suresh700300400
6Kannan600400200
Sheet2


Solution:


Excel Workbook
ABCD
5NameAmountcreditDebit
6Ravi200100100
7Suresh700300400
8Kannan600400200
Sheet1
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
For the amount column, try:
Rich (BB code):
=VLOOKUP($A6,'Sheet2'!$D$1:$G$6,2,0)
Change 2 to 3 for credit column and 2 to 4 for debit column
(keep everything else the same)
 
Upvote 0
Copy B2 Formula to where needed
Excel Workbook
ABCD
1NameAmountcreditDebit
2Ravi200100100
3Suresh700300400
4Kannan600400200
Sheet1
Excel 2007
Cell Formulas
RangeFormula
B2=VLOOKUP($A2,Sheet2!$A$2:$D$6,COLUMN(),FALSE)
Excel Workbook
ABCD
1NameAmountcreditDebit
2Ravi200100100
3Kann500100400
4Sures800200600
5Suresh700300400
6Kannan600400200
Sheet2
Excel 2007
 
Upvote 0
THis is not a VBA code, but this might be what your looking for.

In sheet1, cell B6, type:
=vlookup(A6,'sheet2'!$D$2:$G$6,2,false)
Drag this down the column C6 and D6, changing the 2 to 3 and 4, respectively:

=vlookup(A6,'sheet2'!$D$2:$G$6,3,false)
=vlookup(A6,'sheet2'!$D$2:$G$6,4,false)

Enter the same thing in cell
 
Upvote 0
Record a macro where you type those formula's in and then stop recording
 
Upvote 0
OK,,

Sub Foo()
Range("B2:D4").Formula = "=VLOOKUP($A2,Sheet2!$A$2:$D$6,COLUMN(),FALSE)"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,548
Members
452,927
Latest member
rows and columns

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