Hi,
How can i combine below 2 codes? Also for lookup values i need to combine cells C4&F4. To do is this code makes sense?
How can i combine below 2 codes? Also for lookup values i need to combine cells C4&F4. To do is this code makes sense?
Code:
If Intersect(Target, Target.Worksheet.Range("C4" & "F4")) Is Nothing Then Exit Sub
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xPTable As PivotTable
Dim xPFile As PivotField
Dim xStr As String
On Error Resume Next
If Intersect(Target, Target.Worksheet.Range("B4")) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Set xPTable = Worksheets("Source Data").PivotTables("PivotTable1")
Set xPFile = xPTable.PivotFields("Geography")
xStr = Target.Value
With xPFile
.ClearAllFilters
.PivotFilters.Add2 xlCaptionEquals, Value1:=xStr
End With
Application.ScreenUpdating = True
On Error Resume Next
If Intersect(Target, Target.Worksheet.Range("C4" & "F4")) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Set xPTable = Worksheets("Source Data").PivotTables("PivotTable1")
Set xPFile = xPTable.PivotFields("% Dollar Sales by Merch Any Price Reduction")
xStr = Target.Value
With xPFile
.ClearAllFilters
.PivotFilters.Add2 xlCaptionEquals, Value1:=xStr
End With
Application.ScreenUpdating = True
End Sub