Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

How to pass variable to pivot table parameter?

$
0
0

I want to pass a variable into a value filter for a pivot table.

The code gives me errors.

I'm trying to put the x variable into Value1.

Sub Macro1()
'' Macro1 Macro
'
x = "*" + Range("Sheet1!h17").Value + "*"

ActiveSheet.PivotTables("PivotTable2").PivoJtFields("Note").ClearAllFilters
ActiveSheet.PivotTables("PivotTable2").PivotFields("Note").PivotFilters.Add _
  Type:=xlCaptionContains, Value1:=x

End Sub

Viewing all articles
Browse latest Browse all 88854


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>