How to calculate percentages with VBA

adamjon92

New Member
Joined
Dec 8, 2015
Messages
22
Good morning,

I had a question that I'm hoping isn't too complicated. Basically, I have tonnage in a spreadsheet for multiple carriers, and I need to find an easy way to divide the tonnage for one carrier by the tonnage for all of the carriers combined. For example:

I need to turn this...

Carrier | Tonnage
ABC | 10
DEF | 15
GHI | 25
Total | 50
JKL | 30
MNO | 15
PQR | 25
STU | 30
Total | 100

Into this...

Carrier | Tonnage | Percentage
ABC | 10 | 20%
DEF | 15 | 30%
GHI | 25 | 50%
Total | 50 | 100%
JKL | 30 | 30%
MNO | 15 | 15%
PQR | 25 | 25%
STU | 30 | 30%
Total | 100 | 100%


I already have the carrier and tonnage in my report, but I'm having trouble writing a macro to figure out the percentage.

Any help is appreciated!

Adam
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
you can do this by simply pivoting the data and recreating the original table, then change the field settings to show values as % of total
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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