Runtime error 1004 with ExecuteExcel4Macro

cdfjdk

New Member
Joined
Sep 3, 2014
Messages
31
I have recorded a macro and now it is giving me a runtime error 1004 "There's a problem with this formula" in connection with ExecuteExcel4Macro.


I have tried with double quotes without success
Code:
ExecuteExcel4Macro "(2,1,"""";;;@"""")"
Can anyone point to an error in the code?

Code:
Sub LinkPercent()
'Converts the linked values in Table_Word sheet back to percentages
'
Dim wbk As Workbook
Dim Filename As String
Dim Path As String


Path = "C:\xxx\ExcelFixPct\"
Filename = Dir(Path & "*.xlsx")


Application.DisplayAlerts = False
Application.ScreenUpdating = False


 Do While Len(Filename) > 0


    Set wbk = Workbooks.Open(Path & Filename)


    Sheets("Table_Word").Select
    Range("B7").Select
    ActiveCell.FormulaR1C1 = "=IF('User Form'!R[15]C="""","""",'User Form'!R[15]C)"
    Selection.AutoFill Destination:=Range("B7:J7"), Type:=xlFillDefault
    'Range("B7:J7").Select
    Range("B7").Select
    Selection.NumberFormat = ";;;@"
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=NOT(ISNUMBER('User Form'!B22))"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    ExecuteExcel4Macro "(2,1,"";;;@"")"
    'ExecuteExcel4Macro "(2,1,"""";;;@"""")" '<--double quotes don't help
    Selection.FormatConditions(1).StopIfTrue = False
    Selection.AutoFill Destination:=Range("B7:J7"), Type:=xlFillDefault
    Range("B7:J7").Select
    Selection.NumberFormat = "0.00%"


    wbk.Close savechanges:=True
        
    Filename = Dir
Loop


Application.DisplayAlerts = True
Application.ScreenUpdating = True
    
End Sub
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Fixed.
ExecuteExcel4Macro seems to have little documentation about the use of its parameters, so I have removed it from the macro and just used the format I want
Code:
[COLOR=#333333]NumberFormat = ";;;@"[/COLOR]
instead and that has worked here.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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