Urgent need help with SUM in column

Silverbullet21

New Member
Joined
Mar 13, 2021
Messages
1
Office Version
  1. 2010
Platform
  1. Windows
hi guys, i am a beginner here having problem in writing a dynamic macro that sums up the amount for a particular company that has more than one amount (i.e company C has 4 amounts to be summed up and i need to display the sum amount in beneath the 4 amounts), this same goes to company D with 3 amounts to be added. So basically a macro that will go through the whole column to check if a company has more than one amount and add them, otherwise if only one amount just if ignore. Please help
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Please provide more specific details.
Like search column A for all values below and put sum below last cell with data.
Is that what you want?
And do this on what columns?
Is it column A to Column M?
Or what?
And what is the sheet name?
 
Upvote 0
Why not simply create a PivotTable ??
 
Upvote 0
Welcome to MrExcel Message Board.
1. First If your Data is in Table, Convert to Range (Select one Cell in Table, Design Tab, Convert to Range)
2. Go to Data tab, Subtotal, Then Add Subtotal to Amounts (at Selection Pane with Mark Amount Column = 3rd Option) for Each Company (First Option).
 
Upvote 0
Or Try this Macro:
VBA Code:
Sub Macro1()
Range("A2").Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(4), _
    Replace:=True, PageBreaks:=False, SummaryBelowData:=True
End Sub

1. Cell A2 or One Cell within Your Range
2. Group By: Column Number at your Range (If ComPany Name is First Column then Equal 1
3. TotalList: Number withinArray is ColumnNumber For Amounts at your range ( if Amounts is Column 4 at your Range then Equal Array(4))
 
Upvote 0
I use a Table and do the following:
1. Click any cell in Table Then Click Design Mode
2. Select Total Row. This will add a Total Row at bottom of your table
3. Now on total Row click icon and choose Sum in your case.
4. Now you will see results of the sum for that column
5. Copy that cell and paste where ever you want.
6. Now go back to Design mode unselect Total Row
7. Bingo you have the sum of that column even as you add more values to that column
 
Upvote 0

Forum statistics

Threads
1,214,810
Messages
6,121,690
Members
449,048
Latest member
81jamesacct

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