VBA / Run Time Error '1004'

mjd

Board Regular
Joined
Feb 23, 2010
Messages
73
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):

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
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
You're missing double quotes at the very end

"=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"",""""))))))"
 
Upvote 0
Wow, that really was simple. I can't believe I missed that!

Thanks a million!
 
Upvote 0

Forum statistics

Threads
1,203,683
Messages
6,056,730
Members
444,887
Latest member
cvcc_wt

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