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
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

offthelip

Well-known Member
Joined
Dec 23, 2017
Messages
1,732
Office Version
  1. 2010
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,127,594
Messages
5,625,696
Members
416,127
Latest member
MALEPINZON

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
Top