Lambel
asked on
excel vba autoformat
I want find the row that contains the last record, and then copy a formula that is in the first row, column D, down the whole column. My autofill statement isn't working. Whats wrong with it?
' the fomula to pull the pool counts
Range("A2").Select
lastRw = Range("A" & Rows.Count).End(xlUp).Row + 1
Range("D2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-3],'OH Count Pool'!R2C[-3]:R1000C[-1],3,FALSE)),"""",VLOOKUP(RC[-3],'OH Count Pool'!R2C[-3]:R1000C[-1],3,FALSE))"
Range("D3").Select
' find last record
Selection.AutoFill Destination:=Range(lastRw, "D"), Type:=xlFillDefault
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
The previous comment refers to line 10
ASKER
@ssaqibh: I tried that. Now I get error: "Method 'Range' of object '_Global failed on the autofill.
Did you get both of my comments?
Range("D3").Select
to
Range("D2").Select