+ Reply to Thread
Results 1 to 3 of 3

Count numbers between two values in a coma delimited string of numbers

Hybrid View

van23 Count numbers between two... 12-10-2012, 11:06 PM
rylo Re: Count numbers between two... 12-10-2012, 11:29 PM
van23 Re: Count numbers between two... 12-10-2012, 11:42 PM
  1. #1
    Registered User
    Join Date
    12-08-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    2

    Count numbers between two values in a coma delimited string of numbers

    Hello,
    I'm currently doing this manually and would really appreciate help. I have cells containing a string of numbers separated by comas. I need to count the number of entries that are between two values. Example: Cell F3 contains: 6,11,50,68,120,240 and I need to report there were 3 failures from the range 1-50, 1 from the range 51-100, 1 from 101-150, and 1 from 201-250.
    Example Workbook.xlsx

    Many thanks for the help

    Van23

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Count numbers between two values in a coma delimited string of numbers

    Hi

    How about a UDF

    Function myfunc(rng As Range, loc As String)
      arr = Split(rng, ",")
      Select Case loc
        Case "1-50"
          minn = 0
          maxx = 50
        Case "51-100"
          minn = 51
          maxx = 100
        Case "101-150"
          minn = 101
          maxx = 150
        Case "151-200"
          minn = 151
          maxx = 200
        Case "201-250"
          minn = 201
          maxx = 250
      End Select
      cntr = 0
      For i = LBound(arr) To UBound(arr)
        If Val(arr(i)) >= minn And Val(arr(i)) <= maxx Then cntr = cntr + 1
      Next i
      
      myfunc = cntr
    End Function
    Called by =myfunc($F3,J$2)

    HTH

    rylo

  3. #3
    Registered User
    Join Date
    12-08-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Count numbers between two values in a coma delimited string of numbers

    Thanks for your help rylo, this worked!

+ 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