how to use loop to go down a range

vranjit138

Board Regular
Joined
Dec 18, 2006
Messages
146
Office Version
  1. 365
Platform
  1. Windows
Hi Gurus

I need a simple loop that can march through range and give result in another column


Col A has invoice numbers
Col B has Amounts

in Col D from (D1:D456) i have some invoice numbers
in col E how would i populate the amounts for each row using the vlookup function using For Each ...Next Loop in vba

Please tell

Regards
Ranjit
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi

Code:
x= cells(rows.count,1).end(xlUp).row
y= cells(rows.count,4).end(xlUp).row
b = "A1:B" & x
for a = 1 to y
cells(a,5) = application.worksheetfunction.vlookup(cells(a,4),range(b),2,false)
next a
if you encounter problems, you can subsitute line 4 with
cells(a,5) = "=vlookup(D" & a & ", A1:B" & x & ", 2,false)"
Ravi
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,704
Members
449,048
Latest member
81jamesacct

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