How to make code work in Mac

TanyaD

New Member
Joined
Feb 15, 2018
Messages
17
Hi!

I have got some code that is working beautifully on PC but not when the file is used on Mac. I'm hoping there is a way to get the code to work on both PC and MAC as we have two people needing to use the file, one with PC and one with a MAC. Any suggestions hugely appreciated!

The code is so you can select one or more staff members, and then a date range so you can see the schedule for those selected staff for the selected date range. The code is:

Code:
Sub HideStaffDate()
   Rows(2).Hidden = True
   Rows(3).Hidden = False
      
   Dim Ans As Variant
   Dim Dstart As String, Dend As String
   Dim Cnt  As Long

   Ans = InputBox("Please enter staff member/s (separating names with commas)")
   If Ans = "" Then Exit Sub
   Dstart = InputBox("Enter a start date")
   If Dstart = "" Then Exit Sub
   Dend = InputBox("Enter an end date")
   If Dend = "" Then Exit Sub

   Sheets("Staff").UsedRange.Offset(, 1).EntireColumn.Hidden = False

   For Cnt = 3 To Cells(3, Columns.Count).End(xlToLeft).Column
      If (Cells(3, Cnt) < CDate(Dstart) Or Cells(3, Cnt) > CDate(Dend)) Or InStr(1, Ans, Cells(4, Cnt), vbTextCompare) = 0 Then
         Columns(Cnt).Hidden = True
      End If
   Next Cnt

End Sub

Sorry if there is an obvious solution to this - I am very new to the world of VBA :-)

The other code (to then unhide all columns so can see all staff for all dates) works fine on MAC:
Code:
Sub UnhideAll()
   Rows(2).Hidden = False
   Rows(3).Hidden = True
   Columns.EntireColumn.Hidden = False
End Sub

Thanks for any thoughts on this :-)
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
What version of Excel on each? If possible include the build as well as version number.

What are the symptoms of "not working" on the Mac? Nothing happens at all? Error message? If so, is a line of code highlighted when the user clicks Debug?
 
Upvote 0
Sorry, by 'not working' there are no error messages or any line of code highlighted, it simply just shows the first column (the first staff member only for the first date only), rather than the columns selected (via whatever staff & dates combo).

On the PC the Excel info says:
Microsoft Office Pro Plus 2016 16.0.9029.2253
Version 1802 (Build 9029.2253 Click-to-Run)

On the Mac the Excel info says:
Microsoft Excel for Mac
Version 16.11.1 (180319)

Thanks :-)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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