PDA

View Full Version : Help....for Changing Vba Code in a Pivot for Filtering a Criteria.



Dine
01-18-2016, 08:26 AM
Hi Friends,

Have written a code for a Pivot table having "Description" in report filter as one of the criteria.The ask is the "Description" in the report filter column should not select the below:

Any description containing words :

1. IIT
2 I&IT
3.Device Monitoring - No Issues Reported

Have been successful for the first 2 conditions and been failing for the last condition.

<<<<>>>>

-------------------------------------------------------------------------------------------------------------------


Sub pt1()

Dim pt As PivotTable

Set pt = ActiveSheet.PivotTables("Pttest1")

For Each descpi In pt.PivotFields("Description").PivotItems
If InStr(descpi, "I&IT") > 0 Or InStr(descpi, "IIT") > 0 Or InStr(descpi, "Device Monitoring - No Issues Reported") > 0 Then
descpi.Visible = False
Else
descpi.Visible = True
End If
Next descpi



End Sub

SamT
01-18-2016, 01:37 PM
Try this
If InStr(descpi, "IT") + InStr(LCase(descpi), "no issues") Then

When other numeric types are converted to Boolean values, 0 becomes False and all other values become True. When Boolean values are converted to other data types, False becomes 0 and True becomes -1

Dine
01-19-2016, 09:20 AM
Thanks Sam T its working now...thank you very much for your timely help...