VBA for total and subtotal

anzer

Board Regular
Joined
Mar 5, 2015
Messages
67
Hello,

I have a spreadsheet with column I where there is a lot of data.
I have the 1000 which is the sum of the 2x500 (bold)
The 2x500 are the sum of the data (first one is 200 =300 and second one is sum of 5x100)

I would need a VBA that would populate the formulas taking in consideration the end of the selections
Column I is going down to about I1000 and even more so doing this manually is long and time consuming

Is there a way to do this with VBA? As I have several columns like "I".

Thank you very much

1000sum of the 2 x500
500sum of the 200 and 300 below
200
300
500sum of the 5x100 below
100
100
100
100
100
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Are you trying to do a parent child calculation? Bill of Materials Cost Rollup?
 
Upvote 0
It is liek costs rate total. The 100,200 and 300 would be a formulas to calculate the time and rate of a task. The 500 would be the sum of the tasks. And the 1000 would be the sum of the series of tasks.
 
Upvote 0
Column C Formula
=IF(A2=2,SUM(OFFSET(INDIRECT(ADDRESS(ROW(),2)),0,0,IFERROR(MATCH(2,A3:A12,0),1+COUNTA(A3:A12)))),0)

Column D Formula
=IF(A2=1,SUM(OFFSET(INDIRECT(ADDRESS(ROW(),3)),0,0,IFERROR(MATCH(1,A3:A12,0),1+COUNTA(A3:A12)))),0)

Column E Formula
=SUM(B2:D2)


Snag_92cd91d.png


Snag_92d0a3f.png
 
Upvote 0
Hello VBE! I thought of something like that too! but I would have needed the formulas, but I am still taking your method as of now :) Thank you for your time!
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,845
Members
449,051
Latest member
excelquestion515

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top