Consulting

Results 1 to 6 of 6

Thread: Frequency of a number

  1. #1

    Frequency of a number

    Frequency of a number

    Hello, I would like to know how often one nr appears along with another.

    Best regards
    Leo
    Attached Files Attached Files

  2. #2
    VBAX Expert Leith Ross's Avatar
    Joined
    Oct 2012
    Location
    San Francisco, California
    Posts
    552
    Location
    Hello Leo,

    Put this formula in B3 and drag it down to B53...

    =COUNTIF($C$3:$V$11,A3)
    Sincerely,
    Leith Ross

    "1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG"

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    ... and if you wish to show the "x" then use a custom number format of: 0"x"
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Thankful for the attention, but what I wanted to do is that when the number 3 that I used as an example (B1) appears in a line how many times it coincides with the other numbers. In the example I used the 7 that appears 2 times.

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    In B3 and copy down
    =freq(A3,$B$1,$C$4:$V$11)
    In standard module
    Function Freq(x, y, data)
    Dim Rw As Range, a As Long
    For Each Rw In data.Rows
    a = a + (Not Rw.Find(x, lookat:=xlWhole) Is Nothing) * (Not Rw.Find(y, lookat:=xlWhole) Is Nothing)
    Next
    If x = y Then
    Freq = "#N/A"
    Else
    Freq = a
    End If
    End Function
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    Grateful for the attention, that's what I needed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •