Option Explicit
Sub ForecastChanges()
Dim rPeriodVol As Range
Dim rWeekday As Range
Dim rResiduals As Range
Dim rday As Range
Dim wsVolumeChanges As Worksheet
Dim wsForecasts As Worksheet
Dim wsSummary As Worksheet
Dim wb As Workbook
Dim rdiff As Variant
Dim lngRow As Long
Dim lngrow1 As Long
Dim lngcol As Long
Dim i As Long
Dim j As Long
'set objects
Set wb = ThisWorkbook
Set wsVolumeChanges = wb.Worksheets("Differences")
Set wsSummary = wb.Worksheets("Summary")
Set wsForecasts = wb.Worksheets("Data")
lngRow = wsForecasts.Range("A1").End(xlDown).Row
lngcol = wsForecasts.Range("A1").End(xlToRight).Column
If lngRow > 2 Then
For j = 3 To lngcol
For i = 3 To lngRow
If wsForecasts.Cells(i, 1).Value = wsForecasts.Cells(i - 1, 1).Value Then
If j = 3 Then
wsVolumeChanges.Cells(i - 1, 1).Value = wsForecasts.Cells(i, 1).Value
End If
wsVolumeChanges.Cells(i - 1, j - 1).Value = Abs(wsForecasts.Cells(i, j) - wsForecasts.Cells(i - 1, j)) / 1000
Else
If j = 3 Then
wsVolumeChanges.Cells(i - 1, 1).Value = wsForecasts.Cells(i, 1).Value
End If
wsVolumeChanges.Cells(i - 1, j - 1).Value = 0
End If
Next i
Next j
End If
End Sub