Results 1 to 6 of 6

Double Elimination Sports Tournament Bracket

Threaded View

  1. #3
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,264

    Re: Double Elimination Sports Tournament Bracket

    Try this version - also in the attached.

    Attachment 317316

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        Cancel = True
    
        Dim row As Integer
        Dim col As Integer
        Dim strLoser As String
        Dim rngLoser As Range
        Dim rngGame As Range
        Dim rngNextGame As Range
        Dim rngTitle As Range
        
        row = Target.row
        col = Target.Column + IIf(Target.Column < 7, 1, -1)
        
        If Cells(1, Target.Column).Value > Target.row Then
            Set rngGame = Target.Resize(Cells(1, Target.Column).Value)
            strLoser = rngGame.Cells(rngGame.Cells.Count).Value
            GoTo GotGame
        End If
        If Application.CountA(Target.Resize(Cells(1, Target.Column).Value)) < Application.CountA(Target.Offset(1 - Cells(1, Target.Column).Value).Resize(Cells(1, Target.Column).Value)) Then
            Set rngGame = Target.Offset(1 - Cells(1, Target.Column).Value).Resize(Cells(1, Target.Column).Value)
            strLoser = rngGame.Cells(1).Value
        Else
            Set rngGame = Target.Resize(Cells(1, Target.Column).Value)
            strLoser = rngGame.Cells(rngGame.Cells.Count).Value
        End If
        
    GotGame:
    
        If strLoser = "" Then
            MsgBox "That team had no opponent"
            Exit Sub
        End If
    
        Set rngNextGame = NGame(rngGame, col)
        
        If rngNextGame Is Nothing Then
            MsgBox "Oh-oh - check your color fill for the next game"
            Exit Sub
        End If
        
        Application.EnableEvents = False
        
        If col < Target.Column Then
             rngNextGame.Value = Target.Value
             GoTo ResetEvents
        End If
    
        If rngNextGame.Value <> "" Then
            If MsgBox("This game has already been entered. Change the winner?", vbYesNo) = vbNo Then GoTo ResetEvents
            rngNextGame.Value = Target.Value
            Set rngLoser = Range("G:P").Find(Target.Value, Range("G1"), xlValues, xlWhole)
            rngLoser.Value = strLoser
        Else
            rngNextGame.Value = Target.Value
            Set rngTitle = rngGame.Resize(rngGame.Cells.Count - 2).Offset(1).Find("* G*")
            Set rngLoser = Range("G:P").Find(Application.Trim("Loser " & Mid(rngTitle.Value, InStrRev(rngTitle.Value, " G"))), Range("G1"), xlValues, xlWhole)
            If rngLoser Is Nothing Then
                  MsgBox Application.Trim("Loser " & Mid(rngTitle.Value, InStrRev(rngTitle.Value, " G"))) & "  is missing"
            End If
            rngLoser.Value = strLoser
        End If
    ResetEvents:
        Application.EnableEvents = True
         
    End Sub
    
    Function NGame(r1 As Range, c1 As Integer) As Range
        Dim r As Range
        For Each r In r1
            If Cells(r.row, c1).Interior.ColorIndex = r1.Cells(1).Interior.ColorIndex Then
                Set NGame = Cells(r.row, c1)
                Exit Function
            End If
        Next r
    End Function
    Attached Files Attached Files
    Last edited by Bernie Deitrick; 05-09-2014 at 04:19 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Bracket or Tournament Help
    By rogeru in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-08-2011, 02:11 PM
  2. 2011 NCAA Tournament Bracket
    By bluerog in forum The Water Cooler
    Replies: 1
    Last Post: 03-18-2011, 09:30 AM
  3. Bracket Tournament help
    By Ziggy_Excel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-11-2010, 10:29 AM
  4. Making tournament Bracket
    By chris386 in forum Excel General
    Replies: 1
    Last Post: 06-28-2007, 01:22 PM
  5. Help with Tournament Bracket Generator (with Photos)
    By ghost_rider in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 02-22-2006, 11:39 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