Results 1 to 3 of 3

Problem with macro when used on Excel for Mac

Threaded View

  1. #1
    Registered User
    Join Date
    03-09-2015
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013
    Posts
    13

    Question Problem with macro when used on Excel for Mac

    Hi everyone,

    I am having a problem with a database I made using a PC when used on a Mac. The database involves multiple userforms and pivot tables. After I first experienced a problem I looked into the userforms and realized Active-X buttons wouldn't work with Mac. So I changed the buttons to the form controls. Now, I am using this macro attached to a form control button to update the pivot tables:

    Sub AllWorksheetPivots()
    
    Dim pt As PivotTable
    
        For Each pt In ActiveSheet.PivotTables
    
            pt.RefreshTable
    
        Next pt
    
    End Sub
    That seems to be working fine. Now, I have a report sheet called "Summary Report" that has pivot tables using data from multiple sheets. I only wanted to have to use one set of slicers to control multiple tables from different sources, so I have a hidden sheet called "Master Slicers" that has all of the slicers and I have code written to the "Master Slicers" sheet that lets the user control all of the slicers just by clicking the ones on the "Summary Report" sheet. This code works just fine on my PC but when used on a Mac, it causes Excel to shut down. Here is that code:

    'QUARTER
    
    
    Private Sub Worksheet_PivotTableUpdate _
        (ByVal Target As PivotTable)
    Dim wb As Workbook
    Dim scShort As SlicerCache
    Dim scQuarterly As SlicerCache
    Dim scAnnual As SlicerCache
    Dim scTutoring As SlicerCache
    Dim scCounseling As SlicerCache
    Dim siShort As SlicerItem
    Dim siQuarterly As SlicerItem
    Dim siAnnual As SlicerItem
    Dim siTutoring As SlicerItem
    Dim siCounseling As SlicerItem
    
    Dim scShort2 As SlicerCache
    Dim scQuarterly2 As SlicerCache
    Dim scAnnual2 As SlicerCache
    Dim scTutoring2 As SlicerCache
    Dim scCounseling2 As SlicerCache
    Dim siShort2 As SlicerItem
    Dim siQuarterly2 As SlicerItem
    Dim siAnnual2 As SlicerItem
    Dim siTutoring2 As SlicerItem
    Dim siCounseling2 As SlicerItem
    
    'On Error GoTo errHandler
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    
    Set wb = ThisWorkbook
    Set scShort = wb.SlicerCaches("Slicer_Quarter4")
    Set scQuarterly = wb.SlicerCaches("Slicer_Quarter")
    Set scAnnual = wb.SlicerCaches("Slicer_Quarter1")
    Set scTutoring = wb.SlicerCaches("Slicer_Quarter2")
    Set scCounseling = wb.SlicerCaches("Slicer_Quarter3")
    Set scShort2 = wb.SlicerCaches("Slicer_Year4")
    Set scQuarterly2 = wb.SlicerCaches("Slicer_Year")
    Set scAnnual2 = wb.SlicerCaches("Slicer_Year3")
    Set scTutoring2 = wb.SlicerCaches("Slicer_Year1")
    Set scCounseling2 = wb.SlicerCaches("Slicer_Year2")
    
    scQuarterly.ClearManualFilter
    scAnnual.ClearManualFilter
    scTutoring.ClearManualFilter
    scCounseling.ClearManualFilter
    scQuarterly2.ClearManualFilter
    scAnnual2.ClearManualFilter
    scTutoring2.ClearManualFilter
    scCounseling2.ClearManualFilter
    
    'Quarterly
    
    For Each siQuarterly In scQuarterly.VisibleSlicerItems
        Set siQuarterly = scQuarterly.SlicerItems(siQuarterly.Name)
        Set siShort = Nothing
        On Error Resume Next
        Set siShort = scShort.SlicerItems(siQuarterly.Name)
        'On Error GoTo errHandler
        If Not siShort Is Nothing Then
            If siShort.Selected = True Then
                siQuarterly.Selected = True
            ElseIf siShort.Selected = False Then
                siQuarterly.Selected = False
            End If
        Else
            siQuarterly.Selected = False
        End If
    Next siQuarterly
    
    
    
    For Each siQuarterly2 In scQuarterly2.VisibleSlicerItems
        Set siQuarterly2 = scQuarterly2.SlicerItems(siQuarterly2.Name)
        Set siShort2 = Nothing
        On Error Resume Next
        Set siShort2 = scShort2.SlicerItems(siQuarterly2.Name)
        'On Error GoTo errHandler
        If Not siShort2 Is Nothing Then
            If siShort2.Selected = True Then
                siQuarterly2.Selected = True
            ElseIf siShort2.Selected = False Then
                siQuarterly2.Selected = False
            End If
        Else
            siQuarterly2.Selected = False
        End If
    Next siQuarterly2
    
    
    'Annual
    
    For Each siAnnual In scAnnual.VisibleSlicerItems
        Set siAnnual = scAnnual.SlicerItems(siAnnual.Name)
        Set siShort = Nothing
        On Error Resume Next
        Set siShort = scShort.SlicerItems(siAnnual.Name)
        'On Error GoTo errHandler
        If Not siShort Is Nothing Then
            If siShort.Selected = True Then
                siAnnual.Selected = True
            ElseIf siShort.Selected = False Then
                siAnnual.Selected = False
            End If
        Else
            siAnnual.Selected = False
        End If
    Next siAnnual
    
    
    
    For Each siAnnual2 In scAnnual2.VisibleSlicerItems
        Set siAnnual2 = scAnnual2.SlicerItems(siAnnual2.Name)
        Set siShort2 = Nothing
        On Error Resume Next
        Set siShort2 = scShort2.SlicerItems(siAnnual2.Name)
        'On Error GoTo errHandler
        If Not siShort2 Is Nothing Then
            If siShort2.Selected = True Then
                siAnnual2.Selected = True
            ElseIf siShort2.Selected = False Then
                siAnnual2.Selected = False
            End If
        Else
            siAnnual2.Selected = False
        End If
    Next siAnnual2
    
    
    'Tutoring
    
    For Each siTutoring In scTutoring.VisibleSlicerItems
        Set siTutoring = scTutoring.SlicerItems(siTutoring.Name)
        Set siShort = Nothing
        On Error Resume Next
        Set siShort = scShort.SlicerItems(siTutoring.Name)
        'On Error GoTo errHandler
        If Not siShort Is Nothing Then
            If siShort.Selected = True Then
                siTutoring.Selected = True
            ElseIf siShort.Selected = False Then
                siTutoring.Selected = False
            End If
        Else
            siTutoring.Selected = False
        End If
    Next siTutoring
    
    
    For Each siTutoring2 In scTutoring2.VisibleSlicerItems
        Set siTutoring2 = scTutoring2.SlicerItems(siTutoring.Name)
        Set siShort2 = Nothing
        On Error Resume Next
        Set siShort2 = scShort2.SlicerItems(siTutoring2.Name)
        'On Error GoTo errHandler
        If Not siShort2 Is Nothing Then
            If siShort2.Selected = True Then
                siTutoring2.Selected = True
            ElseIf siShort2.Selected = False Then
                siTutoring2.Selected = False
            End If
        Else
            siTutoring2.Selected = False
        End If
    Next siTutoring2
    
    
    
    'Counseling
    
    For Each siCounseling In scCounseling.VisibleSlicerItems
        Set siCounseling = scCounseling.SlicerItems(siCounseling.Name)
        Set siShort = Nothing
        On Error Resume Next
        Set siShort = scShort.SlicerItems(siCounseling.Name)
        'On Error GoTo errHandler
        If Not siShort Is Nothing Then
            If siShort.Selected = True Then
                siCounseling.Selected = True
            ElseIf siShort.Selected = False Then
                siCounseling.Selected = False
            End If
        Else
            siCounseling.Selected = False
        End If
    Next siCounseling
    
    
    For Each siCounseling2 In scCounseling2.VisibleSlicerItems
        Set siCounseling2 = scCounseling2.SlicerItems(siCounseling2.Name)
        Set siShort2 = Nothing
        On Error Resume Next
        Set siShort2 = scShort2.SlicerItems(siCounseling2.Name)
        'On Error GoTo errHandler
        If Not siShort2 Is Nothing Then
            If siShort2.Selected = True Then
                siCounseling2.Selected = True
            ElseIf siShort2.Selected = False Then
                siCounseling2.Selected = False
            End If
        Else
            siCounseling2.Selected = False
        End If
    Next siCounseling2
    
    
    
    exitHandler:
        Application.ScreenUpdating = True
        Application.EnableEvents = True
        Exit Sub
    
    'errHandler:
     '   MsgBox "Could not update pivot table"
      '  Resume exitHandler
    
    End Sub
    SO, any ideas on why this would work on a PC but not a Mac? I don't have access to a Mac to test on so if anyone has a Mac with the most updated version of Excel I can send the whole file.

    Update: after some research I've read that macros won't run on hidden sheets (which would be the "Master Slicers" sheet - BUT, I'm not sure why this would have worked on my PC if it's not possible at all. ANY insight at all would be appreciated.

    Thank you!

    Alison
    Last edited by alisonhs; 12-21-2015 at 07:09 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem with recording a macro with long formula - works in Excel but not in macro
    By tonybeo2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-28-2015, 11:25 AM
  2. [SOLVED] Excel Macro - Copy & Paste (Font) problem & Delete Last Added Rows problem
    By LennartB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-05-2015, 06:58 AM
  3. [SOLVED] Problem when changing Macro from Excel 2007 (Windows) to Excel 2011 (Mac)
    By TrialandError80 in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 01-02-2014, 07:26 AM
  4. Problem with Excel 2003 macro in Excel 2010.
    By madiaz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-25-2013, 03:27 AM
  5. excel macro problem
    By yvaurin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-12-2005, 07:07 PM
  6. RE: excel macro problem
    By yvautrin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-12-2005, 04:06 PM
  7. RE: excel macro problem
    By Jim Thomlinson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-12-2005, 04:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1