Link to home
Create AccountLog in
Avatar of Lambel
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

Open in new window

Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Change

        Range("D3").Select

to

        Range("D2").Select
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
The previous comment refers to line 10
Avatar of Lambel
Lambel

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?