PC and Mac compatible file

MickJacko

New Member
Joined
Dec 16, 2009
Messages
9
Hi,

I have a small excel file with several macros.
Works fine on a pc, but go to a mac and it does not function.

Anyone got any ideas OR can look at it for me?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
What kind of problems are you encountering?
Filepath issues can be fixed by using Application.PathSeparator instead of "\", but calls to API functions and use of the Dictionary object require the use of conditional compilation.

Also, what kind of "doesn't function"? Errror messages or erroneous results?
 
Upvote 0
Thanks Mike,

We do not get any error messages.
It is for a rugby club which I help to manage.
We create reports based on hiding columns.
The hiding of columns is done in an "Admin tab" where we select what we want to see and then go to the "Report tab" and only the select fields are shown.

Works perfect on a pc, but users on a mac cant run this function.

The VB looks like (which on selection of a checkbox, hides a column in another tab):

Private Sub CheckBox1_Click()
Application.ScreenUpdating = False
If CheckBox1.Value = True Then
Sheet4.Select
Sheet4.Columns("B:B").Select
Selection.EntireColumn.Hidden = False
ElseIf CheckBox1.Value = False Then
Sheet4.Select
Sheet4.Columns("B:B").Select
Selection.EntireColumn.Hidden = True
End If
Sheet3.Select
Application.ScreenUpdating = True


End Sub


Private Sub CheckBox2_Click()
Application.ScreenUpdating = False
If CheckBox2.Value = True Then
Sheet4.Select
Sheet4.Columns("C:C").Select
Selection.EntireColumn.Hidden = False
ElseIf CheckBox2.Value = False Then
Sheet4.Select
Sheet4.Columns("C:C").Select
Selection.EntireColumn.Hidden = True
End If
Sheet3.Select
Application.ScreenUpdating = True
End Sub


Any ideas?
 
Upvote 0
It looks like you are using ActiveX controls. Mac doesn't support ActiveX.
You should be able to translate that into using Forms controls.
 
Upvote 0
If you create a Forms checkbox, named Check Box 1 (note the spaces) and assign it to this sub, it should do the trick. (that's one check box down, N to go. :) )

Note the use of .ControlFormat and that Value = xlOn (or xlOff) rather than True (or False).
Code:
Public Sub CheckBox1Routine()
    Application.ScreenUpdating = False
    If ActiveSheet.Shapes("Check Box 1").ControlFormat.Value = xlOn Then
        Sheet4.Select
        Sheet4.Columns("B:B").Select
        Selection.EntireColumn.Hidden = False
    Else
        Sheet4.Select
        Sheet4.Columns("B:B").Select
        Selection.EntireColumn.Hidden = True
    End If
    Sheet3.Select
    Application.ScreenUpdating = True
End Sub

The unesseary selection can also be removed
Code:
Public Sub CheckBox1Routine()
    Application.ScreenUpdating = False
    If ActiveSheet.Shapes("Check Box 1").ControlFormat.Value = xlOn Then
        Sheet4.Columns("B:B").EntireColumn.Hidden = False
    Else
        Sheet4.Columns("B:B").EntireColumn.Hidden = True
    End If
    Sheet3.Select
    Application.ScreenUpdating = True
End Sub
or
Code:
Public Sub CheckBox1Routine()
    Application.ScreenUpdating = False
   
    Sheet4.Columns("B:B").EntireColumn.Hidden = (ActiveSheet.Shapes("Check Box 1").ControlFormat.Value <> xlOn)
    
    Sheet3.Select
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Consider assigning all the checkboxes to a single routine like:
Code:
Sub AllCheckBox()
Dim ColToHide as Range

With Sheet4
    Select Case Application.Caller
        Case "Check Box 1"
            Set ColToHide = .Range("B:B")
        Case "Check Box 2"
            Set ColToHide = .Range("C:C")
        Case "Check Box 3"
            Set ColToHide = .Range("D:D")
    End Select
End With

ColToHide.EntireColumn.Hidden = (ActiveSheet.Shapes(Application.Caller).ControlFormat.Value <> xlOn)
End Sub
or (if the name/column correspondence is always regular)
Code:
Sub AllCheckBox2()
    Dim ColToHide as Range
    Dim BoxIndex as Long

    BoxIndex = Val(Right(Application.Caller, 2))

    Set ColToHide = Sheet4.Columns(BoxIndex + 1)

    ColToHide.EntireColumn.Hidden = (ActiveSheet.Shapes(Application.Caller).ControlFormat.Value <> xlOn)
End Sub
 
Last edited:
Upvote 0
Hi,

I have tried to make this work with no luck.
Copied code above and lose all functionality - I am doing something wrong.

Any advice OR any interest in doing this for me?
 
Upvote 0

Forum statistics

Threads
1,215,316
Messages
6,124,228
Members
449,149
Latest member
mwdbActuary

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