Gregorys05
Board Regular
- Joined
- Sep 24, 2008
- Messages
- 217
Hi,
i have the below code that keeps erroring when there is not any data for a specific date, how do i get the value to equal 0 if it can not find the data.
Thanks
i have the below code that keeps erroring when there is not any data for a specific date, how do i get the value to equal 0 if it can not find the data.
Rich (BB code):
Sub LoopRow2()
Workbooks.Open Filename:= _
"\\Cofunds\Cofunds\data\AWD BI\Support & Control\AWD BI - Amendment Turnaround & Error Type Analysis v14.xls"
Dim Cell As Range
Dim PT As PivotTable
Set PT = Workbooks("AWD BI - Amendment Turnaround & Error Type Analysis v14.xls").Worksheets("DEALAMEND MI Summary").PivotTables("PivotTable4")
For Each Cell In Workbooks("Dashboard MI Daily.xls").ActiveSheet.Range("M3:AF3")
T = Cell.Value
i = WeekdayName(Weekday(Cell.Value), True, vbSunday)
If Cell.Value = Date Then Exit Sub
If i = "Mon" Then
Select Case T
Case Is < Date
Cell.Offset(1, 0).FormulaR1C1 = PT.GetPivotData("Final P/L", "PROCESSED_DATE", Cell.Value) + PT.GetPivotData("Final P/L", "PROCESSED_DATE", (Cell.Value - 1)) + PT.GetPivotData("Final P/L", "PROCESSED_DATE", (Cell.Value - 2))
End Select
Else
Select Case T
Case Is < Date
Cell.Offset(1, 0).FormulaR1C1 = PT.GetPivotData("Final P/L", "PROCESSED_DATE", Cell.Value)
End Select
End If
Next Cell
End Sub
Thanks