Jan 27 2021 10:19 AM
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
Jan 27 2021 01:26 PM
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