Почистил совсем немного. Я не потрудился зациклить клетки sum
. В вашем коде также отсутствует расчет для Inventory Cost
Sub test()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim lRow As Long
Dim wb As Workbook: Set wb = ThisWorkbook
Dim Sourcews As Worksheet: Set Sourcews = wb.Worksheets("DATA")
Dim Destinationws As Worksheet: Set Destinationws = wb.Worksheets("Report")
With Sourcews
lRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range(.Cells(lRow - 2, 1), .Cells(lRow, 1)).Copy Destination:=Destinationws.Cells(9, 2)
.Range(.Cells(lRow - 2, 3), .Cells(lRow, 3)).Copy Destination:=Destinationws.Cells(9, 3)
.Range(.Cells(lRow - 2, 7), .Cells(lRow, 7)).Copy Destination:=Destinationws.Cells(9, 4)
End With
With Destinationws
' text
.Cells(12, 2).Value = "Total"
.Cells(8, 2).Value = "Month"
.Cells(8, 3).Value = "Production Cost"
.Cells(8, 4).Value = "Inventory Cost"
.Cells(8, 5).Value = "Total Cost"
.Cells(8, 3).Value = "Production Cost"
.Cells(14, 1).Value = "Figure below illustrates the production unit, and the demand time series for the past year; as well as the forecast for the following three months."
.Cells(28, 1).Value = "Figure below illustrates the inventory levels for the past year, as well as the forecast for the following three months."
.Cells(42, 1).Value = "Regards,"
' Inventory Cost calculation needed
.Cells(9, 4).Value = .Cells(9, 4).Value ' * another value?
.Cells(10, 4).Value = .Cells(10, 4).Value ' * another value?
.Cells(11, 4).Value = .Cells(11, 4).Value ' * another value?
' footer totals
.Cells(12, 3).Value = WorksheetFunction.Sum(.Cells(9, 3), .Cells(10, 3), .Cells(11, 3))
.Cells(12, 4).Value = WorksheetFunction.Sum(.Cells(9, 4), .Cells(10, 4), .Cells(11, 4))
.Cells(12, 5).Value = WorksheetFunction.Sum(.Cells(12, 3), .Cells(12, 4))
' right totals
.Cells(9, 5).Value = WorksheetFunction.Sum(.Cells(9, 3), .Cells(9, 4))
.Cells(10, 5).Value = WorksheetFunction.Sum(.Cells(10, 3), .Cells(10, 4))
.Cells(11, 5).Value = WorksheetFunction.Sum(.Cells(11, 3), .Cells(11, 4))
.Columns(2).Resize(, 5).ColumnWidth = 13.71
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub