Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Las Vegas, Nevada, USA
    Posts
    334
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Custom Function, SumBetween (Excel 2003 sp2)

    In the Data Analysis Toolpack a Histogram Function counts the number of occurrences within a range whose values fall between user defined Bin Ranges.

    I would like to sum the values within those Bin Ranges as well, but I have not found a SUMBETWEEN Function. Now I know I could add an adjacent group of columns that would test the values and place their results in the proper columns, but that takes up alot of space and time. A SUMBETWEEN Function that works like COUNTBETWEEN would sum the items. I searched the archives for SUMBETWEEN but found no results.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Custom Function, SumBetween (Excel 2003 sp2)

    CountBetween is a user-defined function that subtracts two COUNTIFs to count the number of items between two values.
    You could create a similar function SumBetween that subtracts two SUMIFs. Or use formulas that subtract two SUMIFs.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Las Vegas, Nevada, USA
    Posts
    334
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Custom Function, SumBetween (Excel 2003 sp2)

    You mean, like this?

    'sumBETWEEN
    Function sumBETWEEN(rng, num1, num2)
    sumBETWEEN = Application.SumIf(rng, "<=" & num2) - Application.SumIf(rng, "<" & num1)
    End Function

    That's too easy!

    Thanks Hans!

Posting Permissions

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