转换windows excel vba代码兼容mac

我有以下4个代码在Windows PC上完美工作。 问题是,它在Mac电脑上使用时无法正常工作。

我没有在mac平台上编码vba的经验,也没有mac pc以及debugging代码。

有一点帮助转换或testing下面的代码在Mac PC将非常感激。

代码1:

Private Sub Workbook_Open() Application.OnKey "^1", "HideSheets" End Sub 

代码2:

 Sub HideSheets() Dim myPassword As String myPassword = "PASSWORD" ' Set password here Password = InputBox("Enter Password") If Password = "" Then Exit Sub ' Exit if no password iputted ' Incorrect password If Password <> myPassword Then MsgBox Title:="Warning", prompt:="Incorrect Password" Exit Sub End If On Error Resume Next ' Correct password If Worksheets("Services").Visible = True Then Worksheets("Services").Visible = xlSheetVeryHidden ActiveSheet.Protect myPassword, True, True Else Worksheets("Services").Visible = True ActiveSheet.Unprotect myPassword End If End Sub 

代码3:

 Private Sub Auto_Close() On Error Resume Next Worksheets("Services").Visible = xlSheetVeryHidden ' Hide worksheets ActiveSheet.Protect "PASSWORD" ActiveWorkbook.Save End Sub 

代码4:

 Private Sub Worksheet_Change(ByVal Target As Range) Dim rRng As Range Dim rCell As Range Set rRng = ActiveSheet.Range("B17:B38") If Not Application.Intersect(rRng, Range(Target.Address)) Is Nothing Then Application.EnableEvents = False With ActiveSheet .Unprotect "PASSWORD" For Each rCell In rRng.Cells Select Case rCell.Value Case "CASE 1", "CASE 2", "CASE 3", "CASE 4", "CASE 5" rCell.Offset(0, 2).Value = 1 rCell.Offset(0, 2).Locked = True Case Else rCell.Offset(0, 2).Locked = False End Select Next rCell End With ActiveSheet.Protect "PASSWORD" Application.EnableEvents = True End If End Sub 

我可以使用下面的子程序来检查用户是否使用Mac或Windows PC。 但由于我没有一个mac pc,我无法debugging,如果我的代码工作正常。

 Sub WINorMAC_1() If Mac Then 'Call the Mac version of the 4 codes above Else 'Call each of the 4 codes above End If End Sub