Results 1 to 9 of 9

Excel 2011 on Mac VBA Macro help works on PC will not on mac.

Threaded View

  1. #1
    Registered User
    Join Date
    06-27-2012
    Location
    othseco correct
    MS-Off Ver
    Excel 2010
    Posts
    37

    Excel 2011 on Mac VBA Macro help works on PC will not on mac.

    I have the VBA code below that works on my windows machine but will not run on my mac. I need to adjust it so it will works on both platforms. I am running Lion and Excel 2011 for mac. Can anybody help. Here is the code.

    Sub ConsolidateWinLoss()
    
        Dim wksARD As Worksheet
        Dim wksGIS As Worksheet
        Dim varARDTeams As Variant
        Dim varGIS As Variant
        Dim varOpponents As Variant
        Dim varOpntWinLoss As Variant
        Dim lngARD As Long
        Dim lngGIS As Long
        Dim lngOpnt As Long
        Dim objDic As Object
        Dim lngWins As Long
        Dim lngLoss As Long
        
        Set wksARD = Worksheets("Automated Ranking Data")
        Set wksGIS = Worksheets("Game Input Sheet")
        
        varARDTeams = wksARD.Range("A3:A" & wksARD.Cells(Rows.Count, 1).End(xlUp).Row)
        varGIS = wksGIS.Range("A3:F" & wksGIS.Cells(Rows.Count, 1).End(xlUp).Row)
        ReDim varOpntWinLoss(LBound(varARDTeams) To UBound(varARDTeams), 1 To 2)
        Set objDic = CreateObject("Scripting.Dictionary")
        objDic.comparemode = 1
        For lngARD = LBound(varARDTeams) To UBound(varARDTeams)
            For lngGIS = LBound(varGIS) To UBound(varGIS)
                If varARDTeams(lngARD, 1) = varGIS(lngGIS, UBound(varGIS, 2) - 1) Then
                    If Not objDic.Exists(varGIS(lngGIS, UBound(varGIS, 2))) Then
                        objDic.Add varGIS(lngGIS, UBound(varGIS, 2)), varGIS(lngGIS, UBound(varGIS, 2))
                    End If
                ElseIf varARDTeams(lngARD, 1) = varGIS(lngGIS, UBound(varGIS, 2)) Then
                    If Not objDic.Exists(varGIS(lngGIS, UBound(varGIS, 2) - 1)) Then
                        objDic.Add varGIS(lngGIS, UBound(varGIS, 2) - 1), varGIS(lngGIS, UBound(varGIS, 2) - 1)
                    End If
                End If
            Next lngGIS
            If objDic.Count <> 0 Then
                varOpponents = objDic.Keys
                For lngOpnt = LBound(varOpponents) To UBound(varOpponents)
                    For lngGIS = LBound(varGIS) To UBound(varGIS)
                        If varGIS(lngGIS, UBound(varGIS, 2)) = varOpponents(lngOpnt) Then
                            lngLoss = lngLoss + 1
                        End If
                        If varGIS(lngGIS, UBound(varGIS, 2) - 1) = varOpponents(lngOpnt) Then
                            lngWins = lngWins + 1
                        End If
                    Next lngGIS
                Next lngOpnt
            End If
            objDic.RemoveAll
            varOpntWinLoss(lngARD, 1) = lngWins: lngWins = 0
            varOpntWinLoss(lngARD, 2) = lngLoss: lngLoss = 0
        Next lngARD
        wksARD.Range("D3").Resize(lngARD - 1, 2).Value = varOpntWinLoss
        
    End Sub
    Last edited by Cutter; 07-26-2012 at 09:07 PM. Reason: Added code tags

Thread Information

Users Browsing this Thread

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

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