+ Reply to Thread
Results 1 to 14 of 14

how to find out repeated rows & then adding the values of 1 column to another column?

  1. #1
    Registered User
    Join Date
    06-21-2010
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    15

    Question how to find out repeated rows & then adding the values of 1 column to another column?

    hi all,

    I've an excel sheet with 3 columns width and a large number of rows. Is there anyway to find out repeated rows (1st and 2nd column element repeated) and if there, adding the 3rd column element of those rows and placing the answer in 4th column in any of the repeated row...

    PS: all elements in cells are positive numbers.


    Thanks in advance...

  2. #2
    Registered User
    Join Date
    07-06-2010
    Location
    Pettsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    I recommend using something like "=if(COUNTIF($B$1:$C$10,A1)>0,Duplicate,Not Duplicate)" in cell D1 and copying it down the entire lenth of the column. You would have to change B1:C10 to fit the sheet you have of course. Then repete the process in column E with "=if(COUNTIF($C$1:$C$10,B1)>0,Duplicate,Not Duplicate)"

  3. #3
    Registered User
    Join Date
    06-21-2010
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    Quote Originally Posted by kleiber2001 View Post
    I recommend using something like "=if(COUNTIF($B$1:$C$10,A1)>0,Duplicate,Not Duplicate)" in cell D1 and copying it down the entire lenth of the column. You would have to change B1:C10 to fit the sheet you have of course. Then repete the process in column E with "=if(COUNTIF($C$1:$C$10,B1)>0,Duplicate,Not Duplicate)"
    I'm sorry, am totally new to this...would u mind explaining the meaning of the code u wrote..

    lets my data is like this
    ****A**********B********** C
    1*** 1********* 21********* 300
    2*** 1********* 21********* 400
    3*** 2********* 30********* 40
    4*** 2********* 30********* 50
    5*** 2********* 30********* 60


    The answer i expect is in D1 or D2 700 (300+400)
    either in D3/D5 = 60+50+40 = 150


    PS: * used for spacing nly
    Last edited by rohit330; 07-06-2010 at 11:03 AM.

  4. #4
    Registered User
    Join Date
    07-06-2010
    Location
    Pettsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    oh, sorry, I misunderstood. Your looking for the sumif command. You would put the following in D1: =SUMIF($B$1:$B$5,B1,$C$1:$C$5) and copy it down to D5

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    These should work for you (in D2)
    =IF(A2&B2=A1&B1,"",SUMIFS($C$2:$C$6,$A$2:$A$6,A2,$B$2:$B$6,B2))

    or
    =IF(A2&B2=A1&B1,"",SUMPRODUCT(--($A$2:$A$6=A2),--($B$2:$B$6=B2),$C$2:$C$6))

    Modify the ranges to fit your data.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Registered User
    Join Date
    06-21-2010
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    Quote Originally Posted by ChemistB View Post
    These should work for you (in D2)
    =IF(A2&B2=A1&B1,"",SUMIFS($C$2:$C$6,$A$2:$A$6,A2,$B$2:$B$6,B2))

    or
    =IF(A2&B2=A1&B1,"",SUMPRODUCT(--($A$2:$A$6=A2),--($B$2:$B$6=B2),$C$2:$C$6))

    Modify the ranges to fit your data.
    Thank u bro...but total number of rows exceed 3000... so...

  7. #7
    Registered User
    Join Date
    06-21-2010
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    Quote Originally Posted by kleiber2001 View Post
    oh, sorry, I misunderstood. Your looking for the sumif command. You would put the following in D1: =SUMIF($B$1:$B$5,B1,$C$1:$C$5) and copy it down to D5
    Thank u bro....total number of rows is 3000+....

  8. #8
    Registered User
    Join Date
    06-21-2010
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    Friends, column is fixed, ie 3
    Rows will be more than 3000....

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    =IF(A2&B2=A1&B1,"",SUMIFS($C$2:$C$3006,$A$2:$A$3006,A2,$B$2:$B$3006,B2))
    Adjust the 3006 to whatever number you need.
    Does that work for you?

  10. #10
    Registered User
    Join Date
    06-21-2010
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    Quote Originally Posted by ChemistB View Post
    =IF(A2&B2=A1&B1,"",SUMIFS($C$2:$C$3006,$A$2:$A$3006,A2,$B$2:$B$3006,B2))
    Adjust the 3006 to whatever number you need.
    Does that work for you?
    Some error came bro..

    These are the steps

    For the case i mention above (cell values as considered )

    For true cdn, it came ""+SUM(A2:C2)

    So error came....

    But, i want sum of 3 column alone bro... not all the elements frm A2 to C2...

    i mean in the abv example for 1 and 21 came same, so true cdn, so i need 300+400 (column c elements)
    Last edited by rohit330; 07-06-2010 at 11:35 AM.

  11. #11
    Registered User
    Join Date
    06-21-2010
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    Friends

    \1

    Consider the above picture...

    i got 700 because 1 and 21 are repeated rows, so added their 3rd colums together, so got 700...(300+400)

    Now, for 2 and 30 repeated rows, their 3rd column elemets sum = 150 (40+60+50)

  12. #12
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    Okay, my formula will only work if the columns are sorted in order which, based on your picture is not the case. The easiest way to do this is to use a dummy column (Col D). In D2 dragged down, =A2&B2. You can hide this column if you like.

    In E2 (dragged down),
    =IF(COUNTIF($D$2:D2,D2)>1,"",SUMIFS($C$2:$C$3006,$A$2:$A$3006,A2,$B$2:$B$3006,B2))
    Note: Not sure of formatting in India, you might need to replace comma's with semicolons.

    That will sum each combination in the first occurance.

  13. #13
    Registered User
    Join Date
    06-21-2010
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    Quote Originally Posted by ChemistB View Post
    Okay, my formula will only work if the columns are sorted in order which, based on your picture is not the case. The easiest way to do this is to use a dummy column (Col D). In D2 dragged down, =A2&B2. You can hide this column if you like.

    In E2 (dragged down),
    =IF(COUNTIF($D$2:D2,D2)>1,"",SUMIFS($C$2:$C$3006,$A$2:$A$3006,A2,$B$2:$B$3006,B2))
    Note: Not sure of formatting in India, you might need to replace comma's with semicolons.

    That will sum each combination in the first occurance.
    Thank u bro...its working i tink..i'm checking now..btw, wud u please explain the logic of the formulas....

  14. #14
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: how to find out repeated rows & then adding the values of 1 column to another col

    =IF(COUNTIF($D$2:D2,D2)>1,"",SUMIFS($C$2:$C$3006,$A$2:$A$3006,A2,$B$2:$B$3006,B2))

    COUNTIF($D$2:D2,D2)>1 checks to see if this is the first occurance of the value. If it's a duplicate, it puts a blank, thus insuring that the SUMIFS statement is only used on the first occurance.

    SUMIFS($C$2:$C$3006,$A$2:$A$3006,A2,$B$2:$B$3006,B2))
    Only available in 2007 and later versions...
    $C$2:$C$3006 is the range you want to sum
    $A$2:$A$3006 is criteria 1 range
    A2 is the criteria 1, in other words, sum all the values between A2 and A3006 if they equal A2
    $B$2:$B$3006,B2 2nd criteria range and criteria. a row must meet both criteria (i.e A2 and B2) to be summed.
    Hope that helped.

+ 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