**HELP** VBA code to insert subtotals

  • Thread starter Thread starter farmer
  • Start date Start date
F

farmer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top