ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Merge rows into one based on value (https://www.excelbanter.com/excel-discussion-misc-queries/110976-merge-rows-into-one-based-value.html)

dpb

Merge rows into one based on value
 
OK, I know there should be an easy way to do this, but...

I want/need to automate a process wherein a downloaded worksheet has
one or more instances where there are two or more rows of data for a
particular quantity. What I need is to total the values of certain
columns in those rows for the matching cells and replace the values in
(say) the last of the matching rows w/ the sum, then remove the extra
rows of partial data.

My attempts have failed to do this in anything at all approaching a
clean method. Can someone give an outline of a macro that would do
such an operation as a model? Thanks.

Example--

Symbol #Shares Cost Close Value
ABCD 324 31.21 34.55 11194.20 ...
ABCD 25 33.00 34.55 863.75 ...
BDDE 100 14.44 12.22 1222.00 ...
....

Wanted end result
Symbol #Shares Cost Close Value
ABCD 349 31.34 34.55 12057.95 ...
BDDE 100 14.44 12.22 1222.00 ...
....

where the cost is the (weighted) average cost and the value is the
total...



All times are GMT +1. The time now is 03:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com