Hello,
I am building a dashboard which contains a revenue overview (monthly). The user of the dashboard selects the start month and end month (e.g. January - July). It would then look like this
I am trying to find a VBA code to calculate the sum per product. This range per product always starts with a fixed cell and has to end with the cell of the last column within the same row. However the last column can change (could be any month of the year).
I already found a way to capture the last column number using this:
But I got stuck creating a WorksheetFunction.Sum that will calculate the sum per product for all months in each row (with a variable end month).
Does any one would have any advise?
Thank you in advance!
I am building a dashboard which contains a revenue overview (monthly). The user of the dashboard selects the start month and end month (e.g. January - July). It would then look like this
SERVICES | January | February | March | April | May | June | July | Total |
Product1 | 152345 | 435156 | 549141 | 234581 | 645127 | 512487 | 157481 | sum |
Product2 | 32457 | 38754 | 64517 | 54781 | 51204 | 54178 | 48761 | sum |
I am trying to find a VBA code to calculate the sum per product. This range per product always starts with a fixed cell and has to end with the cell of the last column within the same row. However the last column can change (could be any month of the year).
I already found a way to capture the last column number using this:
PHP:
Dim LastCol As Long
With ActiveSheet
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
Cells(2, LastCol).Value = WorksheetFunction.Sum(Cells(2,2) ?????)
But I got stuck creating a WorksheetFunction.Sum that will calculate the sum per product for all months in each row (with a variable end month).
Does any one would have any advise?
Thank you in advance!