Hello,
I run a NFL pool with a bunch of my friends from a spreadsheet. I use it as a tool to help me learn new tricks and methods in excel (learning is so much more fun when its not what you get paid to do).
Anyway two years ago I started using a Macro for the scoring and I was hoping to simplify the code. Essentially its a matrix and the macro just compares what is populated in the field where they make their pick to a field that is populated with the winner of the game, then makes the appropriate changes. As I was/am new at this I went the brute force method. The core of the code is below:
Sub Scoring()
If Pick = Winner And Pick = Bonus Then
Pick.Select
With Selection.Interior
.ColorIndex = 4
Pick.Select
Selection.Font.ColorIndex = 0
ScorePos.Value = 1
BonusPos.Value = 1
End With
ElseIf Pick = Winner Then
Pick.Select
With Selection.Interior
.ColorIndex = 35
Pick.Select
Selection.Font.ColorIndex = 0
ScorePos.Value = 1
End With
Else: Pick.Select
With Selection.Interior
.ColorIndex = 45
Pick.Select
Selection.Font.ColorIndex = 0
End With
End If
End Sub
Sub Week01()
Set Pick = Range("H3")
Set Winner = Range("F3")
Set Bonus = Range("D3")
Set ScorePos = Range("AH3")
Set BonusPos = Range("BH3")
Scoring
Set Pick = Range("H4")
Set Winner = Range("F4")
Set Bonus = Range("D4")
Set ScorePos = Range("AH4")
Set BonusPos = Range("BH4")
Scoring
(more of this ad nauseam)
The 'setting' piece repeats 192 times per week (16 games * 12 players) and I have a different macro for each week. As you can imagine this makes for a very long string of code. Due to the repetitive nature I am assuming that there must be another way to do this but Google has failed to provide me much help.
Any help would be greatly appreciated.
Thank you,
Nik
Bookmarks