Autofill with variable starting row

bhman79

Board Regular
Joined
Apr 13, 2010
Messages
56
I'm working my way down a worksheet collection information, so my starting point changes every time I run the code.

Here is the example that is not working:

irow = ActiveCell.Row
Range("A" & irow).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[16],'Cross Data'!C[-4]:C[-2],3,FALSE)"
Dim lastrow As Long
lastrow = Range("B" & Rows.Count).End(xlUp).Row
Range("A" & irow).AutoFill Destination:=Range("A" & irow:A" & lastrow), Type:=xlFillDefault
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Does this work?
Code:
ActiveCell.Resize( Range("B" & Rows.Count).End(xlUp).Row - ActiveCell.Row+1).FormulaR1C1 =  "=VLOOKUP(RC[16],'Cross Data'!C[-4]:C[-2],3,FALSE)"
 
Upvote 0
Please give a better explanation. What is "a worksheet collection information?" What are you trying to accomplish? People are much more likely to help you if you tell them what you are trying to do rather than if you force them to reverse-engineer a block of code without comments.
 
Upvote 0
If you are selecting a cell in column A I think your formula may need a rethink.
 
Upvote 0

Forum statistics

Threads
1,215,516
Messages
6,125,285
Members
449,218
Latest member
Excel Master

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