WEIRD CODE: Work on Windows but does not work on Mac. The error on mac is Named argument already specified

Alligatorwang

New Member
Joined
Jun 14, 2022
Messages
3
Office Version
  1. 2021
  2. 2013
Platform
  1. MacOS
Hi, Please help me on this.

I have a already build up excel sheet from my professor, when I use window system everything runs fine, but I am using it on my mac computer and it just doesnot work and give me a really weird code: Named argument already specified.

I attached the code here:
VBA Code:
Sub ARTable()
' Sorts ARs within section based on Annual Cost Savings
'Utility
Range("C14:F18").Sort _
Key1:=Range("E14:E18"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F14:F18"), Order2:=xlAscending, Header:=xlNo

'Lighting
Range("C21:F25").Sort _
Key1:=Range("E21:E25"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F21:F25"), Order2:=xlAscending, Header:=xlNo

'Motors
Range("C28:F32").Sort _
Key1:=Range("E28:E32"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F28:F32"), Order2:=xlAscending, Header:=xlNo

'Fluid Flow
Range("C35:F39").Sort _
Key1:=Range("E35:E39"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F35:F39"), Order2:=xlAscending, Header:=xlNo

'Compressed Air
Range("C42:F46").Sort _
Key1:=Range("E42:E46"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F42:F46"), Order2:=xlAscending, Header:=xlNo

'Steam
Range("C49:F53").Sort _
Key1:=Range("E49:E53"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F49:F53"), Order2:=xlAscending, Header:=xlNo

'Process Heating
Range("C56:F60").Sort _
Key1:=Range("E56:E60"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F56:F60"), Order2:=xlAscending, Header:=xlNo

'Process Cooling
Range("C63:F67").Sort _
Key1:=Range("E63:E67"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F63:F67"), Order2:=xlAscending, Header:=xlNo

'HVAC
Range("C70:F74").Sort _
Key1:=Range("E70:E74"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F70:F74"), Order2:=xlAscending, Header:=xlNo

'CHP
Range("C77:F81").Sort _
Key1:=Range("E77:E81"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F77:F81"), Order2:=xlAscending, Header:=xlNo

'Refrigeration
Range("C84:F88").Sort _
Key1:=Range("E84:E88"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F84:F88"), Order2:=xlAscending, Header:=xlNo

'Renewables
Range("C92:F96").Sort _
Key1:=Range("E92:E96"), Order1:=xlDescending, Header:=xlNo, _
    Key2:=Range("F92:F96"), Order2:=xlAscending, Header:=xlNo
'End Sub


'Sub UpdateTable()
' Updates AR table - auto hides rows not needed and auto sizes row height

Sheets("AR List").Select
Application.ScreenUpdating = False
Application.Calculation = xlManual

Dim c As Range
    For Each c In Range("B11:B96")
        If c.Value = "" Then
        c.EntireRow.Hidden = True
        Else
        c.EntireRow.Hidden = False
        End If
    Next c

Dim d As Range
    For Each d In Range("B12, B19, B26, B33, B40, B47, B54, B61, B68, B75, B82, B90")
        If d.Value = "" Then
        d.EntireRow.Hidden = True
        d.Offset(-1, 0).EntireRow.Hidden = True
        d.Offset(5, 0).EntireRow.Hidden = True
        Else
        d.EntireRow.Hidden = False
        d.Offset(-1, 0).EntireRow.Hidden = False
        d.Offset(5, 0).EntireRow.Hidden = False
        End If
    Next d
   
Dim e As Range
    For Each e In Range("B90")
        If e.Value = "" Then
        e.Offset(-2, 0).EntireRow.Hidden = True
        Else
        e.Offset(-2, 0).EntireRow.Hidden = False
        End If
    Next e

Application.Calculation = xlAutomatic
Application.ScreenUpdating = True

'Range("B11").Select
'ActiveCell.FormulaR1C1 = "=VLOOKUP(1,Inputs!R[-10]C[9]:RC[10],2,FALSE)"
'Range("B12").Select

End Sub
 
Last edited by a moderator:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Welcome to the Board!

When you get that error, does it give you a "Debug" button you can click?
If so, click it, and let us know what line of code it highlights.
 
Upvote 0
You only use the Header argument once, not for both keys.
 
Upvote 0
Hi Rory, thanks to point out, but I think I only use one header argument, could u tell me where is the second one? Thanks
 
Upvote 0
In every sort you have Header:=xlNo twice
 
Upvote 0

Forum statistics

Threads
1,223,445
Messages
6,172,176
Members
452,446
Latest member
walkman99

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