Trending Sum Macro

pavanranjan

Board Regular
Joined
Sep 20, 2008
Messages
50
Hi Team,
Need help to create a macro for 12 month sliding to right for Sum their values

Yellow marked will be 12 months in a row which is available data
Blue marked
in the desired output post inserting three columns post city column. Grand total formula is also required


1603974961758.png


Tending DSOTending DSOTending DSO202103202103202102202102202102202101202101202101202100202100202100
Customer noCustomer NameCitySalesARDSOSalesARDSOSalesARDSOSalesARDSOSalesARDSO
00123456North CansusNYC40036027
100​
90​
27​
100​
90​
27​
100​
90​
27​
100​
90​
27​
00123457Mount CenaiABC100090027
250​
225​
27​
250​
225​
27​
250​
225​
27​
250​
225​
27​
00123459Holy childZBA1600144027
400​
360​
27​
400​
360​
27​
400​
360​
27​
400​
360​
27​
Total300027002775067527750675277506752775067527
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
try this code:
VBA Code:
Sub test()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
' load all the data to column R
inarr = Range(Cells(1, 1), Cells(lastrow, 18))
For i = 1 To 18
 If inarr(2, i) = "Sales" Or inarr(2, i) = "AR" Then
    tot = 0
   For j = 3 To lastrow
    tot = tot + inarr(j, i)
   Next j
   Range(Cells(lastrow + 1, i), Cells(lastrow + 1, i)) = tot
 End If
If inarr(2, i) = "DSO" Then
 Range(Cells(lastrow + 1, i), Cells(lastrow + 1, i)) = inarr(lastrow, i)
End If
Next i

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,591
Messages
6,125,711
Members
449,252
Latest member
cryss1988

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