# Loop & Sum Subtotal VBA

#### Anilk

##### New Member
Hi,

I have a set of numbers which run like this ...

Amount 1 Amount 2
\$5000
\$200
\$4300
\$1800
\$600
\$2000
\$500
\$1200
\$2000

My Amount count will go to thousands..., How can i write a macro so as it will shown the sum of Amount 2 with corresponding figures in Amount1, and a row inserted after every sub total (matched).......... say..... something like this...

Amount 1 Amount 2
\$5000
\$200
\$4300
\$500

Subtotal \$5000 \$5000

\$1800
\$600
\$1200

Subtotal \$ 1800 \$1800

\$2000
\$2000

Subtotal \$2000 \$2000

Thanks in anticipation for any kind help by you guys please.......

Cheers

AK

### Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
where did the 500 come from in the first subtotal?

oops sorry, the figures shud look like this
Amount 1 Amount 2
\$5000
\$200
\$4300
\$1800
\$600
\$2000
\$500
\$1200
\$2000

and the resultant is somethis like this
Amount 1 Amount 2
\$5000 \$200
\$4300
\$500
Subtotal \$5000 \$5000

\$1800 \$600
\$1200
Subtotal \$1800 \$1800

\$2000 \$2000
Subtotal \$2000 \$2000

actually i am unable to copy my sheet over there...... pls ignore my ignorance

Basically, in this fomrat, there r only 3 amounts in column1

\$5000, \$1800 & \$2000

While the rest (\$200, \$4300, \$500, \$1200, \$600, \$2000)are in Column 2, now i want to make a VBA macro so that all the amounts in col 2 which total to the amount in col 1 can be segregated.

say something like this.
the sum of \$200,\$4300 & \$500 in col 2, corresponds to \$5000 of col 1

Last edited:

Replies
1
Views
306
Replies
6
Views
191
Replies
0
Views
260
Replies
13
Views
687
Replies
10
Views
462

1,214,367
Messages
6,119,117
Members
448,870
Latest member
max_pedreira

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back