VBA Help in Macro

Tcoult20

New Member
Joined
Jun 11, 2014
Messages
1
Hey I am trying to run a macro that fill complete a v-lookup. The v-lookup is being ran in column C and its lookup value is coming from column A. The table array is coming from another workbook. I am wanting the v-lookup to run until it finds an empty cell in column A since the number of values in column A can differ every time. I recorded a macro that put a vlookup in and dragged it down, however it will only go down to the same amount of cells (ex: 300) every time. Here is the code I have as of now. Sub Vlookup()
'
' Vlookup Macro
'
'
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-2],'[Price File 6-1-14.xlsx]ARC'!C2:C17,16,FALSE)"
Selection.AutoFill Destination:=Range("C3:C300"), Type:=xlFillDefault
Range("C3:C300").Select

End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Welcome to the Board!

You can dynamically locate the last row in column A with data like this:
Code:
lastRow = Cells(Rows.Count,"A").End(xlUp).Row
You can then incorporate that into your VBA code, wherever you want to refer to the last row of data.
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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