macro to perform a calculation

pyclen

Board Regular
Joined
Jan 17, 2022
Messages
85
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi all,

I have a table that has calculated cost for several tests at various different timepoints (for demo purposes I made up the table below incl. totals w/ and w/o surcharge)
I have another table w/surcharges that can be applied (0%, 10%, 20%, 30%, 40%)

Is there a way to program a macro or have a switch to apply the selected surcharge to the total as I show below, in other words I want a field/macro above the table that when selected either applies a surcharge directly to the individual cost (i.e., $1100 instead of 1000 for test 1 for example) or at the bottom to the total.
I hope my explanation is clear

Thank you in advance

Time 1Time 2Time 3Time 4
Test 1$1000$2000$2000$1000
Test 2$500$1000$1000$500
Test 3$750$1500$1500$750
Total$2250$4500$4500$2250
total w/10% surcharge$2475$4950$4950
$2475
total w/20% surcharge$2700$5400$5400$2700
total w/30% surcharge$2925$5850$5850$2925
total w/40% surcharge$3150$6300$6300$3150
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
So, do you mean that if there is a 10% surcharge, that you want all the individual values (and Total) in your upper table increased by 10%?
 
Upvote 0
Assuming a Total is the sum of the values, isn't this just Sum(B2:B4)*1.1 for 10% in the surcharge cell/row?
 
Upvote 0
I would like to adjust the cost for each test at each time by the chosen surcharge (i.e. the table would read 1100, 550, 825 (top2bottom) for time 1 with a total of 2475 instead of 1000,500, 750
 
Upvote 0
I would like to adjust the cost for each test at each time by the chosen surcharge (i.e. the table would read 1100, 550, 825 (top2bottom) for time 1 with a total of 2475 instead of 1000,500, 750
OK, can you provide some specifics?
What cell will you be putting this surcharge percentage in?
And what range is your data table that needs updating found in?
 
Upvote 0
For individual surcharge calculations I'd have a rate cell (f'rinstance, A7 contains 1.1 for 10%) and multiply B2 (1000) by A7. The cell with the sum formula will do the rest.

EDIT -I just realized that the title mentions 'macro'?
 
Upvote 0
I think I figured out how to do it, I will make a dropdown for the surcharge and then use an if statement to either perform a summation of rows above only or multiply the sum by the surcharge, no macro needed.

Thanks for helping me brainstorm, had a block
 
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,764
Members
448,991
Latest member
Hanakoro

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