Add up the values of duplicate cells [Solved/Closed]

Sumit - May 17, 2010 at 07:04 AM - Latest reply: rizvisa1 4481 Posts Thursday January 28, 2010Registration dateContributorStatus January 6, 2016 Last seen
- May 19, 2010 at 04:58 AM
Hello,

I am trying to sort out a problem in excel file. I have some duplicate strings in column C and there are some integer values in column D. I want to to add up the adjacent integer values in column D for the duplicate strings in column C.

Now the column A should be searched for that particular duplicated string in Column C and the result of the sum of the integer values should be displayed in the column B adjacent to the same string in Column A.

If a string is not duplicated in column C then the adjacent integer value should be displayed in the column B adjacent to the same string in column A.

A B C D
hello sss 1
sss hello 3
cc cc 4
hello 5
sss 2

The output shud be

A B C D
hello 8 sss 1
sss 3 hello 3
cc 4 cc 4
hello 5
sss 2




Please help me out with the VB code.
See more 

2 replies

rizvisa1 4481 Posts Thursday January 28, 2010Registration dateContributorStatus January 6, 2016 Last seen - May 17, 2010 at 07:08 AM
rizvisa1 4481 Posts Thursday January 28, 2010Registration dateContributorStatus January 6, 2016 Last seen - May 19, 2010 at 04:58 AM
0
Thank you
You can use SUMIF on the worksheet

=IF(A1<>"",SUMIF(C:C,A1,D:D), "")


or in VBA

range("b1:b4").formulaR1C1="=IF(RC1<>"""",SUMIF(C3:C3,RC1,c4:c4), """")"