D
Donald Parker
I'm just learning this, and I am running into a problem I can not
understand.
I've written a VBA macro to put a value is a formula in a cell and then use
the autofill method to extend that formula to an adjacent range.
What I am finding is that the assignment of a formula works fine but the
autofill fails (run-time error 1004 autofill method of range fails).
e.g.
' this next statement works fine
Sheets("calculations").Range("b3").FormulaArray = "=SUM(IF('Raw
Data'!N$3:N$1776=$A3,1,0))"
'this next statement gives me the run time error
Sheets("calculations").Range("b3").AutoFill Destination:=Range("b3:e3"),
Type:=xlFillDefault
I don't think it is an autofill problem ... I've tried simpler things like
just trying to use the select method. I get the same symptoms - run time
error 1004 select method of range fails
e.g.
' this next statement works fine
Sheets("calculations").Range("b3") = "a"
'this next statement gives me the run time error
Sheets("calculations").Range("b3").Select
I've seen almost identical code generated with macro recorder that runs with
no problems. I'm baffled. An answer to this problem would be best, but
probably better advice would be how the heck to debug problems like this.
Thanks!
understand.
I've written a VBA macro to put a value is a formula in a cell and then use
the autofill method to extend that formula to an adjacent range.
What I am finding is that the assignment of a formula works fine but the
autofill fails (run-time error 1004 autofill method of range fails).
e.g.
' this next statement works fine
Sheets("calculations").Range("b3").FormulaArray = "=SUM(IF('Raw
Data'!N$3:N$1776=$A3,1,0))"
'this next statement gives me the run time error
Sheets("calculations").Range("b3").AutoFill Destination:=Range("b3:e3"),
Type:=xlFillDefault
I don't think it is an autofill problem ... I've tried simpler things like
just trying to use the select method. I get the same symptoms - run time
error 1004 select method of range fails
e.g.
' this next statement works fine
Sheets("calculations").Range("b3") = "a"
'this next statement gives me the run time error
Sheets("calculations").Range("b3").Select
I've seen almost identical code generated with macro recorder that runs with
no problems. I'm baffled. An answer to this problem would be best, but
probably better advice would be how the heck to debug problems like this.
Thanks!