Macro generating Runtime error 1004 on PC but not Mac

%3CLINGO-SUB%20id%3D%22lingo-sub-2102936%22%20slang%3D%22en-US%22%3EMacro%20generating%20Runtime%20error%201004%20on%20PC%20but%20not%20Mac%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2102936%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20there!%20I%20have%20a%20simple%20macro%20in%20a%20workbook%20on%20my%20Mac%2C%20which%20works%20perfectly.%20But%20when%20my%20client%20tries%20to%20run%20it%20on%20her%20PC%2C%20she%20gets%20Runtime%20error%201004.%20She%20has%20enabled%20macros%20and%20trusted%20my%20source%2C%20etc.%20I%20also%20had%20her%20paste%20the%20code%20directly%20into%20her%20VBA%20editor%20--%20same%20error.%20Any%20ideas%3F%3F%20Are%20there%20mac%2Fpc%20syntax%20differences%20causing%20an%20issue%3F%20Thank%20you!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECode%20in%20question%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22s1%22%3ESub%3C%2FSPAN%3E%20RefreshPivotTest()%3C%2FP%3E%3CP%20class%3D%22p2%22%3E'%3C%2FP%3E%3CP%20class%3D%22p2%22%3E'%20RefreshPivotTest%20Macro%3C%2FP%3E%3CP%20class%3D%22p2%22%3E'%3C%2FP%3E%3CP%20class%3D%22p1%22%3EThisWorkbook.RefreshAll%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3ERange(%22B7%3AB120%22).Select%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3ESelection.Copy%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3ERange(%22N4%22).Select%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3EActiveSheet.paste%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3ERange(%22I5%3AI120%22).Select%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3EApplication.CutCopyMode%20%3D%20%3CSPAN%20class%3D%22s1%22%3EFalse%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3ESelection.Copy%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3ERange(%22N4%22).Select%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3ESelection.End(xlDown).Offset(1%2C%200).Select%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3EActiveSheet.paste%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3ESelection.End(xlUp).Select%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3ERange(%22N4%3AN236%22).Select%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3EApplication.CutCopyMode%20%3D%20%3CSPAN%20class%3D%22s1%22%3EFalse%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22p1%22%3E%3CSPAN%20class%3D%22Apple-converted-space%22%3E%26nbsp%3B%20%26nbsp%3B%20%3C%2FSPAN%3ERange(%22N4%3AN236%22).RemoveDuplicates%20Columns%3A%3DArray(1)%3C%2FP%3E%3CP%20class%3D%22p3%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22p2%22%3E'%3C%2FP%3E%3CP%20class%3D%22p4%22%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2102936%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2103722%22%20slang%3D%22en-US%22%3ERe%3A%20Macro%20generating%20Runtime%20error%201004%20on%20PC%20but%20not%20Mac%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2103722%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F931000%22%20target%3D%22_blank%22%3E%40tashaflies%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20problem%20appears%20to%20be%20with%20Columns%3A%3DArray(1).%20Try%20this%20version%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3ESub%20RefreshPivotTest()%0A'%0A'%20RefreshPivotTest%20Macro%0A'%0A%20%20%20%20ThisWorkbook.RefreshAll%0A%20%20%20%20Range(%22B7%3AB120%22).Copy%20Destination%3A%3DRange(%22N4%22)%0A%20%20%20%20Range(%22I5%3AI120%22).Copy%20Destination%3A%3DRange(%22N4%22).End(xlDown).Offset(1%2C%200)%0A%20%20%20%20Range(%22N4%3AN236%22).RemoveDuplicates%20Columns%3A%3D1%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi there! I have a simple macro in a workbook on my Mac, which works perfectly. But when my client tries to run it on her PC, she gets Runtime error 1004. She has enabled macros and trusted my source, etc. I also had her paste the code directly into her VBA editor -- same error. Any ideas?? Are there mac/pc syntax differences causing an issue? Thank you!

 

Code in question:

 

Sub RefreshPivotTest()

'

' RefreshPivotTest Macro

'

ThisWorkbook.RefreshAll

    Range("B7:B120").Select

    Selection.Copy

    Range("N4").Select

    ActiveSheet.paste

    Range("I5:I120").Select

    Application.CutCopyMode = False

    Selection.Copy

    Range("N4").Select

    Selection.End(xlDown).Offset(1, 0).Select

    ActiveSheet.paste

    Selection.End(xlUp).Select

    Range("N4:N236").Select

    Application.CutCopyMode = False

    Range("N4:N236").RemoveDuplicates Columns:=Array(1)

 

'

End Sub

1 Reply

@tashaflies 

The problem appears to be with Columns:=Array(1). Try this version:

 

Sub RefreshPivotTest()
'
' RefreshPivotTest Macro
'
    ThisWorkbook.RefreshAll
    Range("B7:B120").Copy Destination:=Range("N4")
    Range("I5:I120").Copy Destination:=Range("N4").End(xlDown).Offset(1, 0)
    Range("N4:N236").RemoveDuplicates Columns:=1
End Sub