ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Data validation to control a pivot table field (https://www.excelbanter.com/excel-programming/386586-data-validation-control-pivot-table-field.html)

FA

Data validation to control a pivot table field
 
I have the following VBA. I use it to change a Pivot table with a data
validation cell. The problem that I have is that when the pivot table should
show "All" it will overwrite the latest selection.

How can I change that in order to make it select "All" when required?

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("k1")) Is Nothing Then Exit Sub

Application.EnableEvents = False
Worksheets("Sales").PivotTables("Pivottable1") _
.PageFields("Alpha Name --------------------").CurrentPage =
Target.Value
Application.EnableEvents = True

End Sub


All times are GMT +1. The time now is 05:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com