macro to figure % of summed catergories

instanceoftime

Board Regular
Joined
Mar 23, 2011
Messages
102
I have a list of categories. This list in column A and figures in column B.
The number of rows (catergories) some sheets may have 5 categories and others may have 50.

What I am looking for help with is the sum of column B (can be placed at end of last row in column)
and subsequent % of value that category makes up of the total. (to be placed in column C )

I have been doing this manually and it is getting extensive lol. Can I please get some help?

btw: the Xl2bb is AMAZING!!!!!

Happy Holidays

cstSUM-3779039.csv
ABC
1Category$%
2Bathroom/Kitchen Hardware1389.960.204334
3Pool Items699.990.102904
4Fans714.820.105084
5Patio Furniture1399.930.2058
6Dining Furniture779.970.114661
7Safes399.990.058801
8Flooring751.780.110517
9Wet/Dry Vacs319.990.047041
10Beach Gear345.960.050859
116802.39
output
Cell Formulas
RangeFormula
C2:C10C2=B2/B$11
B11B11=SUM(B2:B10)
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Try running this from the active sheet.

VBA Code:
Sub ctsSum()
    Dim LRow As Long
    LRow = Cells(Rows.Count, "B").End(xlUp).Row    
    Cells(LRow + 1, 2).Formula = Application.Sum(Range(Cells(2, 2), Cells(LRow, 2)))
    Range(Cells(2, 3), Cells(LRow, 3)).FormulaR1C1 = _
    "=(RC2/R" & LRow + 1 & "C2)"
End Sub
 
Upvote 0
Try running this from the active sheet.

VBA Code:
Sub ctsSum()
    Dim LRow As Long
    LRow = Cells(Rows.Count, "B").End(xlUp).Row 
    Cells(LRow + 1, 2).Formula = Application.Sum(Range(Cells(2, 2), Cells(LRow, 2)))
    Range(Cells(2, 3), Cells(LRow, 3)).FormulaR1C1 = _
    "=(RC2/R" & LRow + 1 & "C2)"
End Sub
Awesome works perfect! I thought I could 'adapt' it but you lost me at hello.... How can I do this using column E & F instead of A & B? with the result in G (sorry was trying to keep it simple)
 
Upvote 0
You could also simply use a Pivot table
 
Upvote 0
Awesome works perfect! I thought I could 'adapt' it but you lost me at hello.... How can I do this using column E & F instead of A & B? with the result in G (sorry was trying to keep it simple)
Like this
VBA Code:
Sub ctsSum()
    Dim LRow As Long
    LRow = Cells(Rows.Count, "F").End(xlUp).Row
    Cells(LRow + 1, 6).Formula = Application.Sum(Range(Cells(2, 6), Cells(LRow, 6)))
    Range(Cells(2, 7), Cells(LRow, 7)).FormulaR1C1 = _
    "=(RC6/R" & LRow + 1 & "C6)"
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,430
Messages
6,124,850
Members
449,194
Latest member
HellScout

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