counting occurences of cell matches

L

Lee H

Hi - I'm a golf fanatic trying to do some analysis of my golf scores,
counting the number of pars, birdies, bogeys I get during any given round of
golf. Assume two rows, 18 columns; I want to count the number of of
occurences that the top row cell (for example B1) equals the bottom row cell
(B2); how often the top row cell (C1 for example) = bottom row cell (C2 for
example) +1; how often the top row cell = bottom row cell -1; etc. The top
row is par for the hole, remains constant; The second row is my score on that
hole. The formulas provide me with the number of pars, birdies bogeys etc I
get on any given round of golf. Thanks
 
J

JLGWhiz

Assuming that Row 1 will be the hole numbers and Column A will be for
players names:

Sub golf()
Dim P As Range
For Each p In Range("B2:S2")
If P.Value = P.Offset(1, 0) Then
Par = Par + 1
ElseIf p.Value - 1 = P.Offset(1, 0) Then
Birdie = Birdie + 1
ElseIf p.Value - 2 = P.Offset(1, 0) Then
Eagle = Eagle + 1
ElseIf p.Value + 1 = P.Offset(0, 1) Then
Bogey = Bogey + 1
Elseif p.Value + 2 = p.Offset(0, 1) Then
DBogey = DBogey + 1
Else
Throw_out = Throw_out + 1
End If
Next
MsgBox Par & " Pars." & vbLf & _
Birdie & " Birdies." & vbLf _
Eagle & " Eagles." & vbLf _
Bogey & " Bogeys." & vbLf _
DBogey & " Double Bogeys." & vbLf _
Throw_out & " Throw out holes."
End Sub

This will give you the whole picture.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top