Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-14-2008, 06:47 AM
paulkaye
 
Posts: n/a
Adding items in a column if value in a second column is X.

Hi,
This one is getting the better of me, even though I know I should be
able to figure it out myself!:

I have two columns of data: B and C.
I have one column of ID#: A

I would like to subtract C from B in all rows where ID# is X and
display the sum of these values in a single cell. I would then like to
do the same for all rows where ID# is Y.

Please help!

Many thanks for your time,

Paul
Reply With Quote
  #2 (permalink)  
Old 01-14-2008, 09:37 AM
Pete_UK
 
Posts: n/a
Re: Adding items in a column if value in a second column is X.

Try these:

=SUMPRODUCT((A1:A100="X")*(B1:B100-C1:C100))

=SUMPRODUCT((A1:A100="Y")*(B1:B100-C1:C100))

Adjust column ranges to suit, but you can't have a complete column
(unless you have XL2007).

Hope this helps.

Pete



On Jan 14, 6:47*am, paulkaye <paulmjk...@gmail.com> wrote:
> Hi,
> This one is getting the better of me, even though I know I should be
> able to figure it out myself!:
>
> I have two columns of data: B and C.
> I have one column of ID#: A
>
> I would like to subtract C from B in all rows where ID# is X and
> display the sum of these values in a single cell. I would then like to
> do the same for all rows where ID# is Y.
>
> Please help!
>
> Many thanks for your time,
>
> Paul


Reply With Quote
  #3 (permalink)  
Old 01-14-2008, 09:37 AM
Pete_UK
 
Posts: n/a
Re: Adding items in a column if value in a second column is X.

Try these:

=SUMPRODUCT((A1:A100="X")*(B1:B100-C1:C100))

=SUMPRODUCT((A1:A100="Y")*(B1:B100-C1:C100))

Adjust column ranges to suit, but you can't have a complete column
(unless you have XL2007).

Hope this helps.

Pete



On Jan 14, 6:47*am, paulkaye <paulmjk...@gmail.com> wrote:
> Hi,
> This one is getting the better of me, even though I know I should be
> able to figure it out myself!:
>
> I have two columns of data: B and C.
> I have one column of ID#: A
>
> I would like to subtract C from B in all rows where ID# is X and
> display the sum of these values in a single cell. I would then like to
> do the same for all rows where ID# is Y.
>
> Please help!
>
> Many thanks for your time,
>
> Paul


Reply With Quote
  #4 (permalink)  
Old 01-14-2008, 10:08 AM
paulkaye
 
Posts: n/a
Re: Adding items in a column if value in a second column is X.

Hi,

I got a #VALUE! error.

I don't quite understand the formula - it looks like it does something
like:

A1*(B1-C1)
+A2*(B2-C2)
+A3*(B3-C3)
....

Could you explain? I was expecting to do something with IF statements!

Many thanks again for your time,

Paul

On Jan 14, 11:37 am, Pete_UK <pashu...@auditel.net> wrote:
> Try these:
>
> =SUMPRODUCT((A1:A100="X")*(B1:B100-C1:C100))
>
> =SUMPRODUCT((A1:A100="Y")*(B1:B100-C1:C100))
>
> Adjust column ranges to suit, but you can't have a complete column
> (unless you have XL2007).
>
> Hope this helps.
>
> Pete
>
> On Jan 14, 6:47 am, paulkaye <paulmjk...@gmail.com> wrote:
>
> > Hi,
> > This one is getting the better of me, even though I know I should be
> > able to figure it out myself!:

>
> > I have two columns of data: B and C.
> > I have one column of ID#: A

>
> > I would like to subtract C from B in all rows where ID# is X and
> > display the sum of these values in a single cell. I would then like to
> > do the same for all rows where ID# is Y.

>
> > Please help!

>
> > Many thanks for your time,

>
> > Paul


Reply With Quote
  #5 (permalink)  
Old 01-14-2008, 10:08 AM
paulkaye
 
Posts: n/a
Re: Adding items in a column if value in a second column is X.

Hi,

I got a #VALUE! error.

I don't quite understand the formula - it looks like it does something
like:

A1*(B1-C1)
+A2*(B2-C2)
+A3*(B3-C3)
....

Could you explain? I was expecting to do something with IF statements!

Many thanks again for your time,

Paul

On Jan 14, 11:37 am, Pete_UK <pashu...@auditel.net> wrote:
> Try these:
>
> =SUMPRODUCT((A1:A100="X")*(B1:B100-C1:C100))
>
> =SUMPRODUCT((A1:A100="Y")*(B1:B100-C1:C100))
>
> Adjust column ranges to suit, but you can't have a complete column
> (unless you have XL2007).
>
> Hope this helps.
>
> Pete
>
> On Jan 14, 6:47 am, paulkaye <paulmjk...@gmail.com> wrote:
>
> > Hi,
> > This one is getting the better of me, even though I know I should be
> > able to figure it out myself!:

>
> > I have two columns of data: B and C.
> > I have one column of ID#: A

>
> > I would like to subtract C from B in all rows where ID# is X and
> > display the sum of these values in a single cell. I would then like to
> > do the same for all rows where ID# is Y.

>
> > Please help!

>
> > Many thanks for your time,

>
> > Paul


Reply With Quote
  #6 (permalink)  
Old 01-14-2008, 10:58 AM
Pete_UK
 
Posts: n/a
Re: Adding items in a column if value in a second column is X.

The first part of the formula (A1:A100="X") is in fact a conditional
statement which will check in turn if A1="X", A2="X", A3="X" etc and
return TRUE or FALSE as appropriate, which will be interpreted as 1 or
0 respectively. Hence:

(1 or 0)*(B1-C1)
+(1 or 0)*(B2-C2)
+(1 or 0)*(B3-C3)

will give (Bx - Cx) only where Ax = "X", which is what you want.

Check that you have proper numbers in columns B and C, and not text
values. An alternative that you might like to try is:

=SUMPRODUCT(--(A1:A100="X"),(B1:B100-C1:C100))

Hope this helps.

Pete


On Jan 14, 10:08*am, paulkaye <paulmjk...@gmail.com> wrote:
> Hi,
>
> I got a #VALUE! error.
>
> I don't quite understand the formula - it looks like it does something
> like:
>
> * A1*(B1-C1)
> +A2*(B2-C2)
> +A3*(B3-C3)
> ...
>
> Could you explain? I was expecting to do something with IF statements!
>
> Many thanks again for your time,
>
> Paul
>
> On Jan 14, 11:37 am, Pete_UK <pashu...@auditel.net> wrote:
>
>
>
> > Try these:

>
> > =SUMPRODUCT((A1:A100="X")*(B1:B100-C1:C100))

>
> > =SUMPRODUCT((A1:A100="Y")*(B1:B100-C1:C100))

>
> > Adjust column ranges to suit, but you can't have a complete column
> > (unless you have XL2007).

>
> > Hope this helps.

>
> > Pete

>
> > On Jan 14, 6:47 am, paulkaye <paulmjk...@gmail.com> wrote:

>
> > > Hi,
> > > This one is getting the better of me, even though I know I should be
> > > able to figure it out myself!:

>
> > > I have two columns of data: B and C.
> > > I have one column of ID#: A

>
> > > I would like to subtract C from B in all rows where ID# is X and
> > > display the sum of these values in a single cell. I would then like to
> > > do the same for all rows where ID# is Y.

>
> > > Please help!

>
> > > Many thanks for your time,

>
> > > Paul- Hide quoted text -

>
> - Show quoted text -


Reply With Quote
  #7 (permalink)  
Old 01-14-2008, 10:58 AM
Pete_UK
 
Posts: n/a
Re: Adding items in a column if value in a second column is X.

The first part of the formula (A1:A100="X") is in fact a conditional
statement which will check in turn if A1="X", A2="X", A3="X" etc and
return TRUE or FALSE as appropriate, which will be interpreted as 1 or
0 respectively. Hence:

(1 or 0)*(B1-C1)
+(1 or 0)*(B2-C2)
+(1 or 0)*(B3-C3)

will give (Bx - Cx) only where Ax = "X", which is what you want.

Check that you have proper numbers in columns B and C, and not text
values. An alternative that you might like to try is:

=SUMPRODUCT(--(A1:A100="X"),(B1:B100-C1:C100))

Hope this helps.

Pete


On Jan 14, 10:08*am, paulkaye <paulmjk...@gmail.com> wrote:
> Hi,
>
> I got a #VALUE! error.
>
> I don't quite understand the formula - it looks like it does something
> like:
>
> * A1*(B1-C1)
> +A2*(B2-C2)
> +A3*(B3-C3)
> ...
>
> Could you explain? I was expecting to do something with IF statements!
>
> Many thanks again for your time,
>
> Paul
>
> On Jan 14, 11:37 am, Pete_UK <pashu...@auditel.net> wrote:
>
>
>
> > Try these:

>
> > =SUMPRODUCT((A1:A100="X")*(B1:B100-C1:C100))

>
> > =SUMPRODUCT((A1:A100="Y")*(B1:B100-C1:C100))

>
> > Adjust column ranges to suit, but you can't have a complete column
> > (unless you have XL2007).

>
> > Hope this helps.

>
> > Pete

>
> > On Jan 14, 6:47 am, paulkaye <paulmjk...@gmail.com> wrote:

>
> > > Hi,
> > > This one is getting the better of me, even though I know I should be
> > > able to figure it out myself!:

>
> > > I have two columns of data: B and C.
> > > I have one column of ID#: A

>
> > > I would like to subtract C from B in all rows where ID# is X and
> > > display the sum of these values in a single cell. I would then like to
> > > do the same for all rows where ID# is Y.

>
> > > Please help!

>
> > > Many thanks for your time,

>
> > > Paul- Hide quoted text -

>
> - Show quoted text -


Reply With Quote
  #8 (permalink)  
Old 01-15-2008, 08:27 AM
paulkaye
 
Posts: n/a
Re: Adding items in a column if value in a second column is X.

Ah, thank you for that explanation - now I understand what the formula
is doing. I obviously simplified the spreadsheet description in my
original question but cannot seem to get the correct result. Here is
how I have extended your suggestion:

=SUMPRODUCT((AND($C$6:$C$1000="103",$D$6:$D$1000=" 120ml")*($I$6:$I
$1000)))

As you can see, there are two conditions. I want to add up the values
in column I for product 103 (column C) in size 120ml (column D). I'm
getting zero as the result every time. Is there an error in the
formula I've entered here? Just for your info, I'm intending to extend
the formula further (by using INDIRECT to reference the formula and
size names) once I've got this correct.

Many thanks for your time,

Paul

On Jan 14, 12:58 pm, Pete_UK <pashu...@auditel.net> wrote:
> The first part of the formula (A1:A100="X") is in fact a conditional
> statement which will check in turn if A1="X", A2="X", A3="X" etc and
> return TRUE or FALSE as appropriate, which will be interpreted as 1 or
> 0 respectively. Hence:
>
> (1 or 0)*(B1-C1)
> +(1 or 0)*(B2-C2)
> +(1 or 0)*(B3-C3)
>
> will give (Bx - Cx) only where Ax = "X", which is what you want.
>
> Check that you have proper numbers in columns B and C, and not text
> values. An alternative that you might like to try is:
>
> =SUMPRODUCT(--(A1:A100="X"),(B1:B100-C1:C100))
>
> Hope this helps.
>
> Pete
>
> On Jan 14, 10:08 am, paulkaye <paulmjk...@gmail.com> wrote:
>
> > Hi,

>
> > I got a #VALUE! error.

>
> > I don't quite understand the formula - it looks like it does something
> > like:

>
> > A1*(B1-C1)
> > +A2*(B2-C2)
> > +A3*(B3-C3)
> > ...

>
> > Could you explain? I was expecting to do something with IF statements!

>
> > Many thanks again for your time,

>
> > Paul

>
> > On Jan 14, 11:37 am, Pete_UK <pashu...@auditel.net> wrote:

>
> > > Try these:

>
> > > =SUMPRODUCT((A1:A100="X")*(B1:B100-C1:C100))

>
> > > =SUMPRODUCT((A1:A100="Y")*(B1:B100-C1:C100))

>
> > > Adjust column ranges to suit, but you can't have a complete column
> > > (unless you have XL2007).

>
> > > Hope this helps.

>
> > > Pete

>
> > > On Jan 14, 6:47 am, paulkaye <paulmjk...@gmail.com> wrote:

>
> > > > Hi,
> > > > This one is getting the better of me, even though I know I should be
> > > > able to figure it out myself!:

>
> > > > I have two columns of data: B and C.
> > > > I have one column of ID#: A

>
> > > > I would like to subtract C from B in all rows where ID# is X and
> > > > display the sum of these values in a single cell. I would then like to
> > > > do the same for all rows where ID# is Y.

>
> > > > Please help!

>
> > > > Many thanks for your time,

>
> > > > Paul- Hide quoted text -

>
> > - Show quoted text -


Reply With Quote
  #9 (permalink)  
Old 01-15-2008, 08:27 AM
paulkaye
 
Posts: n/a
Re: Adding items in a column if value in a second column is X.

Ah, thank you for that explanation - now I understand what the formula
is doing. I obviously simplified the spreadsheet description in my
original question but cannot seem to get the correct result. Here is
how I have extended your suggestion:

=SUMPRODUCT((AND($C$6:$C$1000="103",$D$6:$D$1000=" 120ml")*($I$6:$I
$1000)))

As you can see, there are two conditions. I want to add up the values
in column I for product 103 (column C) in size 120ml (column D). I'm
getting zero as the result every time. Is there an error in the
formula I've entered here? Just for your info, I'm intending to extend
the formula further (by using INDIRECT to reference the formula and
size names) once I've got this correct.

Many thanks for your time,

Paul

On Jan 14, 12:58 pm, Pete_UK <pashu...@auditel.net> wrote:
> The first part of the formula (A1:A100="X") is in fact a conditional
> statement which will check in turn if A1="X", A2="X", A3="X" etc and
> return TRUE or FALSE as appropriate, which will be interpreted as 1 or
> 0 respectively. Hence:
>
> (1 or 0)*(B1-C1)
> +(1 or 0)*(B2-C2)
> +(1 or 0)*(B3-C3)
>
> will give (Bx - Cx) only where Ax = "X", which is what you want.
>
> Check that you have proper numbers in columns B and C, and not text
> values. An alternative that you might like to try is:
>
> =SUMPRODUCT(--(A1:A100="X"),(B1:B100-C1:C100))
>
> Hope this helps.
>
> Pete
>
> On Jan 14, 10:08 am, paulkaye <paulmjk...@gmail.com> wrote:
>
> > Hi,

>
> > I got a #VALUE! error.

>
> > I don't quite understand the formula - it looks like it does something
> > like:

>
> > A1*(B1-C1)
> > +A2*(B2-C2)
> > +A3*(B3-C3)
> > ...

>
> > Could you explain? I was expecting to do something with IF statements!

>
> > Many thanks again for your time,

>
> > Paul

>
> > On Jan 14, 11:37 am, Pete_UK <pashu...@auditel.net> wrote:

>
> > > Try these:

>
> > > =SUMPRODUCT((A1:A100="X")*(B1:B100-C1:C100))

>
> > > =SUMPRODUCT((A1:A100="Y")*(B1:B100-C1:C100))

>
> > > Adjust column ranges to suit, but you can't have a complete column
> > > (unless you have XL2007).

>
> > > Hope this helps.

>
> > > Pete

>
> > > On Jan 14, 6:47 am, paulkaye <paulmjk...@gmail.com> wrote:

>
> > > > Hi,
> > > > This one is getting the better of me, even though I know I should be
> > > > able to figure it out myself!:

>
> > > > I have two columns of data: B and C.
> > > > I have one column of ID#: A

>
> > > > I would like to subtract C from B in all rows where ID# is X and
> > > > display the sum of these values in a single cell. I would then like to
> > > > do the same for all rows where ID# is Y.

>
> > > > Please help!

>
> > > > Many thanks for your time,

>
> > > > Paul- Hide quoted text -

>
> > - Show quoted text -


Reply With Quote
  #10 (permalink)  
Old 01-15-2008, 09:21 AM
Pete_UK
 
Posts: n/a
Re: Adding items in a column if value in a second column is X.

Hi Paul,

no need for the AND, as the * does the same job - you can re-write it
as:

=SUMPRODUCT(($C$6:$C$1000="103")*($D$6:$D$1000="12 0ml")*($I$6:$I
$1000))

The only other concern I have is whether your product codes are
numbers or text in column C - you might have to write the first bit
as:

($C$6:$C$1000=103)

You can put the values in different cells, eg M1, N1, and then your
formula becomes:

=SUMPRODUCT(($C$6:$C$1000=M1)*($D$6:$D$1000=N1)*($ I$6:$I$1000))

This way you can change the values easily without having to change the
formula. Also, if the formula is in cell O1 then you can put other
values in M and N and copy the formula down.

Hope this helps.

Pete

On Jan 15, 8:27*am, paulkaye <paulmjk...@gmail.com> wrote:
> Ah, thank you for that explanation - now I understand what the formula
> is doing. I obviously simplified the spreadsheet description in my
> original question but cannot seem to get the correct result. Here is
> how I have extended your suggestion:
>
> =SUMPRODUCT((AND($C$6:$C$1000="103",$D$6:$D$1000=" 120ml")*($I$6:$I
> $1000)))
>
> As you can see, there are two conditions. I want to add up the values
> in column I for product 103 (column C) in size 120ml (column D). I'm
> getting zero as the result every time. Is there an error in the
> formula I've entered here? Just for your info, I'm intending to extend
> the formula further (by using INDIRECT to reference the formula and
> size names) once I've got this correct.
>
> Many thanks for your time,
>
> Paul
>
> On Jan 14, 12:58 pm, Pete_UK <pashu...@auditel.net> wrote:
>
>
>
> > The first part of the formula (A1:A100="X") is in fact a conditional
> > statement which will check in turn if A1="X", A2="X", A3="X" etc and
> > return TRUE or FALSE as appropriate, which will be interpreted as 1 or
> > 0 respectively. Hence:

>
> > *(1 or 0)*(B1-C1)
> > +(1 or 0)*(B2-C2)
> > +(1 or 0)*(B3-C3)

>
> > will give (Bx - Cx) only where Ax = "X", which is what you want.

>
> > Check that you have proper numbers in columns B and C, and not text
> > values. An alternative that you might like to try is:

>
> > =SUMPRODUCT(--(A1:A100="X"),(B1:B100-C1:C100))

>
> > Hope this helps.

>
> > Pete

>
> > On Jan 14, 10:08 am, paulkaye <paulmjk...@gmail.com> wrote:

>
> > > Hi,

>
> > > I got a #VALUE! error.

>
> > > I don't quite understand the formula - it looks like it does something
> > > like:

>
> > > * A1*(B1-C1)
> > > +A2*(B2-C2)
> > > +A3*(B3-C3)
> > > ...

>
> > > Could you explain? I was expecting to do something with IF statements!

>
> > > Many thanks again for your time,

>
> > > Paul

>
> > > On Jan 14, 11:37 am, Pete_UK <pashu...@auditel.net> wrote:

>
> > > > Try these:

>
> > > > =SUMPRODUCT((A1:A100="X")*(B1:B100-C1:C100))

>
> > > > =SUMPRODUCT((A1:A100="Y")*(B1:B100-C1:C100))

>
> > > > Adjust column ranges to suit, but you can't have a complete column
> > > > (unless you have XL2007).

>
> > > > Hope this helps.

>
> > > > Pete

>
> > > > On Jan 14, 6:47 am, paulkaye <paulmjk...@gmail.com> wrote:

>
> > > > > Hi,
> > > > > This one is getting the better of me, even though I know I should be
> > > > > able to figure it out myself!:

>
> > > > > I have two columns of data: B and C.
> > > > > I have one column of ID#: A

>
> > > > > I would like to subtract C from B in all rows where ID# is X and
> > > > > display the sum of these values in a single cell. I would then like to
> > > > > do the same for all rows where ID# is Y.

>
> > > > > Please help!

>
> > > > > Many thanks for your time,

>
> > > > > Paul- Hide quoted text -

>
> > > - Show quoted text -- Hide quoted text -

>
> - Show quoted text -


Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:56 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Loans | Read this exciting weblog | Anime | Credit Counseling | Loans



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114