Selection change code asks to save as Macro

LisetteR

New Member
Joined
May 16, 2011
Messages
6
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
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top