View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
farmer[_2_] farmer[_2_] is offline
external usenet poster
 
Posts: 11
Default **HELP** VBA code to insert subtotals

Hi,

I've got a question.

I would like to use vba code to loop trough a worksheet and insert
subtotals

Let say this is de worksheet:

A B C D E

500100 2100 $ 10,000.00 $ 6,000.00 $ 17,000.00
500100 2110 $ 15,000.00 $ 4,000.00 $ 20,000.00
500100 2120 $ 10,000.00 $ 6,000.00 $ 17,000.00
500200 2100 $ 12,000.00 $ 6,000.00 $ 15,000.00
500200 2100 $ 10,000.00 $ 6,000.00 $ 17,000.00
500200 2100 $ 18,000.00 $ 9,000.00 $ 16,000.00
500300 2100 $ 10,000.00 $ 6,000.00 $ 27,000.00
500300 2100 $ 10,000.00 $ 7,000.00 $ 17,000.00
500300 2100 $ 19,000.00 $ 6,000.00 $ 37,000.00

The desired result should be something like this.

A B C D E

500100 2100 $ 10,000.00 $ 6,000.00 $ 17,000.00
500100 2110 $ 15,000.00 $ 4,000.00 $ 20,000.00
500100 2120 $ 10,000.00 $ 6,000.00 $ 17,000.00
subtotal $ 35,000,00 $ 16,000.00 $ 54,000.00

500200 2100 $ 12,000.00 $ 6,000.00 $ 15,000.00
500200 2100 $ 10,000.00 $ 6,000.00 $ 17,000.00
500200 2100 $ 18,000.00 $ 9,000.00 $ 16,000.00
subtotal $ 40,000,00 $ 21,000.00 $ 38,000.00

500300 2100 $ 10,000.00 $ 6,000.00 $ 27,000.00
500300 2100 $ 10,000.00 $ 7,000.00 $ 17,000.00
500300 2100 $ 19,000.00 $ 6,000.00 $ 37,000.00
subtotal $ 39,000,00 $ 19,000.00 $ 81,000.00

grandtotal $ 114,000.00 $ 56,000.00 $ 173,000.00


Does anyone has an example on how to get a result as shown above?

Help appreciated,

Farmer