A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Hi Berloni
Please, try the following macro
Sub Macro1()
Dim x As Integer 'row number
Dim d As Date 'Date
Range("BE2:BE9000").Value = ""
x = 2
Do While Sheets("LOAD").Cells(x, 3) <> Empty
If Sheets("LOAD").Cells(x, 49) <> Empty Then
d = Sheets("LOAD").Cells(x, 49).Value 'manufacturing date
Else
If Sheets("LOAD").Cells(x, 50) <> Empty Then
d = Sheets("LOAD").Cells(x, 50).Value 'Expected ship date
Else
d = Sheets("LOAD").Cells(x, 26).Value 'Promised ship date
End If
End If
If d - Date < 0 Then
Sheets("LOAD").Cells(x, 57).Value = -1
Else
Sheets("LOAD").Cells(x, 57).Value = d - Date
End If
x = x + 1
Loop
'Pivot refresh
With Sheets("Past").PivotTables("PivotTable1")
.PivotSelect "'-1'", xlDataAndLabel, True
.PivotCache.Refresh
End With
With Sheets("Today").PivotTables("PivotTable1")
.PivotSelect "'0'", xlDataAndLabel, True
.PivotCache.Refresh
End With
With Sheets("Today+1").PivotTables("PivotTable1")
.PivotSelect "'0'", xlDataAndLabel, True
.PivotCache.Refresh
End With
With Sheets("Today+2").PivotTables("PivotTable1")
.PivotSelect "'0'", xlDataAndLabel, True
.PivotCache.Refresh
End With
End Sub