
.
ion Explicit
Sub 月次残高集計()
Dim Sp As Integer, Ep As Integer, Cc As Integer, Idx As Integer
Dim Li As Long, Lo As Long
‘ Worksheets(“月次決算”).Range(“C4:D15”).ClearContents
Worksheets(“月次決算”).Range(“C4:D15”).Value = 0
‘ Application.ScreenUpdating = False
With Worksheets(“元帳”)
Sp = 4
Ep = .Cells(4, 1).End(xlDown).Row
For Cc = Sp To Ep
Idx = Month(.Cells(Cc, 1).Value)
If Idx <= 3 Then Idx = Idx + 12
Li = .Cells(Cc, 4).Value
Lo = .Cells(Cc, 5).Value
With Worksheets(“月次決算”)
.Cells(Idx, 3).Value = .Cells(Idx, 3).Value + Li
.Cells(Idx, 4).Value = .Cells(Idx, 4).Value + Lo
End With
Next Cc
End With
‘ Application.ScreenUpdating = True
Charts.Add
With ActiveChart
.ChartType = xlLineMarkers
.SetSourceData Source:=Sheets(“月次決算”).Range(“B3:E15”), PlotBy:=xlColumns
.Location Where:=xlLocationAsNewSheet
.HasTitle = True
.ChartTitle.Characters.Text = “月次残高”
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.HasDataTable = False
End With
MsgBox “確認したら、何かキーを押してください”, vbOKOnly, “グラフシートの削除”
Application.DisplayAlerts = False
ActiveChart.Delete
Application.DisplayAlerts = True
End Sub



