Pages

Showing posts with label conditional formatting. Show all posts
Showing posts with label conditional formatting. Show all posts

Sunday

Building the Excel basketball bracket

The NCAA March Madness bracket and Basketball Pool Manager file in Excel were very popular this year (over 10000 downloads, which isn't bad considering I haven't attempted any publicizing or SEO), and Nick at Excel Spreadsheets Help asked me to write a guest post about the brackets. I've reprinted the post below with some additional babbling, or you click here to read the original.

-----------------------------------

The process of administering an NCAA basketball pool can be tedious and fraught with human error. To alleviate this, we can use a two-file Excel solution: a Bracket file submitted by all pool participants, and a Pool Manager file used to track the results once the tournament has begun.

Below is a basic overview, but I recommend poking around the files to learn more. Please bear in mind that the bracket files aren't perfect, and there are better ways that I've often been too lazy to implement. The building of these was a long, very incremental process. I built the first bracket in 2002 and usually only worked on the files for a day or two each March, implementing minor changes each year. It's certainly not the best way to build a program, and it's far too typical of how products are developed. Still, the current files serve their purpose and I hope they can be of interest.

The Brackets

Most importantly: we need good, clean data. Let's say there is a game involving Massachusetts. If the participant puts the winner as "UMass," a human with context knowledge understands what that means, but Excel doesn't. The file needs to have "Massachusetts" exactly.

To keep data consistent, all participants must submit the exact same bracket file. By using VBA code that allows the user to click on a cell to advance that team, there is no opportunity for mis-typing. The user clicks on "Massachusetts" in cell B4 and it automatically advances the cell's contents ("Massachusetts") to cell C5. The user sees this as a quick and easy way to fill out a bracket; in reality, its main purpose was to help ensure good data.

For users who don't/can't enable macros, the file also uses a combination of Data Validation, formulas, and Conditional Formatting to ensure clean data. Having alternative checks is an important component to maintaining clean data. Many thanks to my friend Tom Szarek for the clever design of these great VBA-free features.

Collecting the brackets

With everyone using the same bracket file, we always know what data is going to be in which cells - e.g., C5 will always have the winner of the upper-left region's 1-16 matchup. This allows the Pool Manager file's VBA code to open a participant's bracket (previously saved off to the pool administrator's hard drive), store the picks in an array, and then write those picks at a row of data in the Pool Manager file. This is automatically repeated for all participants, storing all pool participant data on the same worksheet. At this point, the Bracket files are no longer of any use.

Evaluating the brackets

Using formulas, we compare the actual winners of the games (from the MasterBracket tab) with the participant's picks. If 'actual winner' on MasterBracket = the 'pick' on the Picks tab, the participant earns the points from that game. For example, if the pool manager designates "Massachusetts" as the winner in cell C5 on the MasterBracket tab, the formulas will check the participant data in column B of the Picks tab for a match. It does the same for the remaining games, the results of which are in Picks!C:C, Picks!D:D, etc.

The participant score is computed instantly with formulas on the Leaders tab. VBA then sorts the leaderboard in descending order so the highest scorer is on top. The resorting could be done with some array formulas, similar to those used on the PartInfo tab, but VBA is easier and less resource intensive.

Enjoy March!

Any time you are doing the same task multiple times, you need to question how Excel and VBA can be used to reduce the workload. With these files, pool administrators can handle a large number of participants with little additional effort. Further, once the Pool Manager file has all data, the administrator can send the file to all pool participants -- this lets participants track scores on their own, generate scenarios, and see other pool participants' picks. The less time spent on administration, the more time there is to enjoy the games and the taunting of friends in the pool.

Monday

NCAA Basketball March Madness Excel Brackets

Please see the new, permanent brackets page at
http://whistleblows.com/brackets/
All new updates will be put on that page. You can also click the "Brackets" link in the page header.


If you are managing a basketball pool of NCAA brackets, or you know someone who is, please feel free to download the NCAA Basketball Pool Manager file. This is used in conjunction with the basketball bracket file to automatically tabulate results, highlight winners in brackets, and cross out losing games. It allows scenario generation and modifying of point totals for each round (since each person prefers his/her own point total weighting, it allows for some customization).

Please feel free to share these files, but I ask that you reference this site when you do so. Also, these files are intended for not-for-profit use.

Note:The files are already populated with the 2010 NCAA tournament field, but I did not make any programming enhancements over last year's version.

March Madness Excel Bracket


Click here to download the basketball bracket. When prompted, choose to save this file to your computer (the desktop is fine). Microsoft Excel is needed in order to use this program. It works best when macros are enabled (see below for info on macros). If you cannot use macros (because of security settings or personal preference), you will not be able to one-click to advance teams, but the bracket is still very easy to complete. Many thanks to Tom Szarek for developing the macroless capabilities.

You will find instructions on the first tab for filling out the bracket (it just involves clicking). The basketball bracket is on the second tab. Once done, save the file and submit it to your pool manager.

Basketball Pool Manager File


This requires Microsoft Excel and macros must be enabled. See below for info on macros.

Click here to download the NCAA basketball bracket pool manager file. This is free code. Please share with others, make your own improvements, or offer suggestions for future upgrades. Please let me know how the program has worked for you - I'd love to hear your stories.

Note: This has been extensively tested using Excel 2002 (part of MS Office XP) and Excel 2007 on Windows XP and Vista platforms. You may see errors if you use this file on a different Excel/Windows version or on a Macintosh computer, but these should not cause any damage to your computer. Please feel free to alert me about any bugs; if they're easy to fix, I'll make the changes and post a new version of the file.

Enjoy!


I hope that you enjoy watching the tournament and that these Excel basketball bracket files somehow contribute to your fun. ~B. David Tyler

While I understand that some people choose to gamble on the NCAA tournament results, the effort is not meant to either endorse or enable gambling. I share this as a way for you to brag to peers about your superior basketball clairvoyance. Please note that this is not supported by or in any way connected to the NCAA.


Macros


How to do I enable macros to use the Bracket file?
Excel 97-2003
When opening the document, select ENABLE MACROS when prompted to do so. If you are not prompted, check your security settings under: Tools... Options... Security... Macro Security... [set your level to "Medium", then click OK twice]. Once this is done, close Excel completely and reopen the document.

Excel 2007
After the document opens, click on the "Options…" box at the top of the screen. In the following window, click "Enable this content" and then "Ok".

What is a macro?
When talking about Microsoft Office (Word, Excel, etc), a macro is a piece of hand-generated code that adds functionality to the software application; the code is written in the "Visual Basic for Applications" language and is part of the Excel file. In the case of the bracket, I wrote code to automatically advance teams through the bracket when you click on the team names; this is not something that Excel does normally, but through macros I could tell Excel exactly what I want to happen.

What is the exact macro code in the bracket file?
Good for you to ask. Open the Excel document and press Alt-F11. This will open up the Visual Basic editor, and by clicking on sheet and module names on the left side of the screen you will be able to view all code.