Home

Cumulative count formula

DownUnderling51
Occasional Visitor

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

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 Sub

 

Hope that helps

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
22 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies