ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   counting occurences of cell matches (https://www.excelbanter.com/excel-programming/422631-counting-occurences-cell-matches.html)

Lee H

counting occurences of cell matches
 
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

JLGWhiz

counting occurences of cell matches
 

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.





"Lee H" wrote:

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



All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com