+ Reply to Thread
Results 1 to 28 of 28

Search and count matching values in each column

Hybrid View

  1. #1
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Search and count matching values in each column

    Here's a new version of the UDF you can use with more than one row in the second parameter:

    Option Explicit
    
    Function RangeCheck(dataRNG As Range, Offsets As Range, MyValues As Range) As Long
    Dim col As Long, r As Range
    
    If dataRNG.Columns.Count <> Offsets.Columns.Count Or dataRNG.Columns.Count <> MyValues.Columns.Count Then
        RangeCheck = -99999
        Exit Function
    End If
    
    For col = 1 To dataRNG.Columns.Count
        For Each r In Offsets.Cells(1, col).Resize(Offsets.Rows.Count)
            If dataRNG.Cells(dataRNG.Rows.Count - r.Value + 1, col) = MyValues(col) Then
                RangeCheck = RangeCheck + 1
                GoTo NextCol
            End If
        Next r
    NextCol:
    Next col
    
    End Function

    Used as: =RangeCheck($B$23:$H$42, $J33:$P42, $W$42:$AC$42)
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1