Summing with a range of number

  • Thread starter Thread starter garungaha1
  • Start date Start date
G

garungaha1

Hey Everyone,

I have a question about summing via ranges. I am trying to write
macro and have hit a bump.

Here is the scenario. I have a 2 columns of data (A&B). Column B i
sorted in ascending order. Now I have ranges of data in column A that
need to sum. Lets say in column B I need all numbers from 100 to 300
From 100 to 300 I need the totals in column A to sum at the last numbe
that is less than 300 but greater than 100. I would like the sum to b
in colum C for the totals of column A within the ranges of column B.
hope that makes sense. If not ask for clarification or I will try an
post a part of the woksheet. Thanks
 
You can calculate the sum of the range by taking the difference of tw
*SUMIF* functions. The first *SUMIF* will count the number o
occurences of numbers in Column B that are less than 300 (values 1
299). Since this first part takes ALL numbers below 300 and you wan
to exclude another range, you will want to subtract from this total al
numbers that are below 101 (values from 1 to 100.) This will give yo
the total for the numbers 101 - 299. Hope that makes sense to you.


=SUMIF(B:B,"<300",A:A)-SUMIF(B:B,"<101",A:A)


You should be able to use VBA to set the formula automatically for yo
based on your criteria.






Rolli
 
Back
Top