View Single Post
  #8   Report Post  
Bryan Hessey
 
Posts: n/a
Default


Robert,

To answer your original question, and not being well up on VBA code, I
imagine that you would start with two zero totals, then run through
each cell of your range testing and adding to either total as required,
then save the two totals into cells, however, this is a waste of effort,
to do what Excel already does.

The formula shown by Biff can be copied straight into the cell in which
you want the total to appear,
in D1 put a 1
in E1 put 1.3
in F1 put 10
into the cell you want the total of 1 to 1.3 range put
=SUMPRODUCT(--(A1:A5=D1),--(A1:A5<=E1),B1:B5)

and into the cell you want the total of what is over 1.3 and under 10
put
=SUMPRODUCT(--(A1:A5=E1),--(A1:A5<=F1),B1:B5)

and no VBA code is required.

Looking at your request I think it possible that you could have used:
=SUMif(A1:A5,"<=1.3",B1:B5)
=SUMif(A1:A5,"1.3",1:B5)

but the Sumproduct as shown will achieve more variations for future
needs.

Hope this helps.


SailFL Wrote:
The only one with bad manners here is you, Harald. Because some one
doesn't
know how to do some thing or doesn't understand is not a problem here.
That
is the purpose of these message boards. So he can't type big deal. I
bet
you didn't always know everthing!
--
SailFL


"Harald Staff" wrote:

It makes perfect sense, you're just too ignorant to implement it. If

your
manners weren't as bad as your spelling then someone might consider

helping
you with it.

"Robert" skrev i melding
...
This doesn't make any snese. How do I put this formula in a

macro.
Please
explain. Thankks.
--
RSF


"Biff" wrote:

Hi!

Column A = decimal values
Column B = integer values

D1 = 1
E1 = 1.3

=SUMPRODUCT(--(A1:A5=D1),--(A1:A5<=E1),B1:B5)

Biff

"Robert" wrote in message
...
I am trying todo something which I "thought" would be simple.

I have a column of number from 0 through 77. I have another

column
beside
of it. The numbers are like this:

1 5
1.1 6
1.3 4
1.35 5
1.5 6

All the way to 77.

I am trying to write a code in VBA that says, basically, if the

value
in
this cell is between (for instance, 1 and 1.3 then sum the

values from
the
corresponding column. The answer to the above would be 15.

ELSE, if
the
values are between 1.35 and 1.5, then sum the values in the

corresponding
column (the answer being 11) and so on. I wanted to store the

answer
values
in specified cells on the same worksheet. Can someone please

help?
Thanks.
--
RSF








--
Bryan Hessey
------------------------------------------------------------------------
Bryan Hessey's Profile: http://www.excelforum.com/member.php...o&userid=21059
View this thread: http://www.excelforum.com/showthread...hreadid=397419