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

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.

ravishankar

Well-known Member
Joined
Feb 23, 2006
Messages
3,566
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,191,119
Messages
5,984,758
Members
439,909
Latest member
daigoku

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