Hi,
I am using Excel 2010 and have a sheet called DailyProgressReport.
When a date is changed in cell I3 I would like to filter 2 pivot tables on other sheets.
I have written the following code under the sheet name in the VBA app, but when I try to run the code in VBA it asks to create a new macro. Could someone explain what I am doing wrong?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$I$3" Then
Dim DPRDate As String
DPRDate = Range("I3")
Worksheets("DailyProgressReport").PivotTables("DPR_Log").PivotFields("Date").ClearAllFilters
Worksheets("DailyProgressReport").PivotTables("DPR_Log").PivotFields("Date").PivotFilters.Add Type _
:=xlSpecificDate, Value1:=DPRDate
Worksheets("AreaLines").PivotTables("DailyCumulativeTotals").PivotFields("Max Date Flown").ClearAllFilters
Worksheets("AreaLines").PivotTables("DailyCumulativeTotals").PivotFields("Max Date Flown"). _
PivotFilters.Add Type:=xlSpecificDate, Value1:=DPRDate
End If
End Sub
I'm very rusty at this, so all help is gratefully received!
Lisette
I am using Excel 2010 and have a sheet called DailyProgressReport.
When a date is changed in cell I3 I would like to filter 2 pivot tables on other sheets.
I have written the following code under the sheet name in the VBA app, but when I try to run the code in VBA it asks to create a new macro. Could someone explain what I am doing wrong?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$I$3" Then
Dim DPRDate As String
DPRDate = Range("I3")
Worksheets("DailyProgressReport").PivotTables("DPR_Log").PivotFields("Date").ClearAllFilters
Worksheets("DailyProgressReport").PivotTables("DPR_Log").PivotFields("Date").PivotFilters.Add Type _
:=xlSpecificDate, Value1:=DPRDate
Worksheets("AreaLines").PivotTables("DailyCumulativeTotals").PivotFields("Max Date Flown").ClearAllFilters
Worksheets("AreaLines").PivotTables("DailyCumulativeTotals").PivotFields("Max Date Flown"). _
PivotFilters.Add Type:=xlSpecificDate, Value1:=DPRDate
End If
End Sub
I'm very rusty at this, so all help is gratefully received!
Lisette