using vlookup to loop for a range of cells

vranjit138

Board Regular
Joined
Dec 18, 2006
Messages
141
hi friends

I have Invoice Numbers starting from range A1 to A4450 and in range B1 onwards i have Vendor Names . in the Vendor Report which begins in Range D6:d450, i have the invoice numbers and i require the vendor names there.. and i have to get the result for invoices in range D6:D450
in column E. how can i get the vlookup values by click of a button . the control button is taken from control toolbox

Please help

Regards
Ranjit
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

ravishankar

Well-known Member
Joined
Feb 23, 2006
Messages
3,566
Hi
Paste the following codes in the macro window ( Alt F11)
Code:
Sub vendor()
For a = 6 To 450
Cells(a, 5) = Application.WorksheetFunction.VLookup(Cells(a, 4), Range("A1:B4450"), 2, False)
Next a
End Sub
Run the macro. It will lookup invoice numbers of colD in col A and returns matching vendor name in col E
Ravi
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
Why loop?
Code:
Private Sub CommandButton1_Click()
With Range("e6:e450")
     .Formula = "=vlookup(d6,$a$1:$b$4450,2,false)"
     .Value = .Value
End With
End Sub
 

Forum statistics

Threads
1,181,055
Messages
5,927,862
Members
436,573
Latest member
CMR237

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
Top