Forum Discussion
DownUnderling51
Dec 21, 2018Copper Contributor
Cumulative count formula
Is there a way to count the number of occurrences of particular randomly generated values as they are generated?
Specifically:
Numbers from 1 to 10 are randomly generated in a particular cell.
Is there a formula to calculate the number of 1's and 2's etc that are generated cumulatively?
1 Reply
Sort By
- Haytham AmairahSilver Contributor
Hi,
You definitely need to a VBA code to do so!
So I would suggest this one below and you will find it in the attached file.
Sub CountTheNumberOfRandomlyGeneratedValueCumulatively()
Dim cell As Range
For Each cell In Range("C1:C10")
If cell.Value = Range("A1").Value Then
cell.Offset(0, 1).Value = cell.Offset(0, 1).Value + 1
Exit For
End If
Next
End SubHope that helps