View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
FA FA is offline
external usenet poster
 
Posts: 18
Default 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