Hi,
I am currently writing an excel (2003) macro to paste formulas into a specific sheet in a workbook. I am getting the following error on the macro:
Run Time Error '1004'
Unable to Set the FormulaArray Property of the Range Class
Here is the code of the macro (the part that is breaking is in red):
I am not too savvy when it comes to VBA, so for all I know this is a simple thing to fix. I appreciate your time in reading this.
Thanks in advance,
Mike
I am currently writing an excel (2003) macro to paste formulas into a specific sheet in a workbook. I am getting the following error on the macro:
Run Time Error '1004'
Unable to Set the FormulaArray Property of the Range Class
Here is the code of the macro (the part that is breaking is in red):
Code:
Sub formulas()
Range("a1").Select
Range("Sheet1!A1").Select
Selection.FormulaArray = _
"=IF(macro!A1="""","""",macro!A1)"
Selection.AutoFill Destination:=Range("Sheet1!a1:a" & Cells(Rows.Count, 1).End(xlUp).Row)
Range("Sheet1!B1").Select
Selection.FormulaArray = _
"=IF(macro!A1="""","""",VLOOKUP(macro!A1,'xxxxx Accts'!A1:B10000,2,FALSE))"
Selection.AutoFill Destination:=Range("Sheet1!b1:b" & Cells(Rows.Count, 1).End(xlUp).Row)
[COLOR=red]Range("Sheet1!c1").Select[/COLOR]
[COLOR=red] Selection.FormulaArray = _[/COLOR]
[COLOR=red] "=IF(macro!B1=""MSPRCV"",""li"",IF(macro!B1=""MSPDLV"",""lo"",IF(macro!B1=""INT"",""in"",IF(macro!B1=""DIV"",""li"",IF(AND(macro!B1=""FEEADV"",macro!E1<0),""dp"",IF(AND(macro!B1=""FEEADV"",macro!E1>0),""wd"",""))))))"[/COLOR]
[COLOR=red] Selection.AutoFill Destination:=Range("Sheet1!c1:c" & Cells(Rows.Count, 1).End(xlUp).Row)[/COLOR]
Range("Sheet1!D1").Select
Selection.FormulaArray = _
"=IF(macro!D1="""","""",macro!D1)"
Selection.AutoFill Destination:=Range("Sheet1!d1:d" & Cells(Rows.Count, 1).End(xlUp).Row)
Range("Sheet1!e1").Select
Selection.FormulaArray = _
"=IF(macro!E1="""","""",macro!E1)"
Selection.AutoFill Destination:=Range("Sheet1!e1:e" & Cells(Rows.Count, 1).End(xlUp).Row)
End Sub
I am not too savvy when it comes to VBA, so for all I know this is a simple thing to fix. I appreciate your time in reading this.
Thanks in advance,
Mike