I'm new to VBA. I have an excel file with a pivot table created by OLAP Cube. I try to create a variable that filters a specific column within the Pivot Table.
I used Record Macro and this is what I've got:
Sub Macro1()
ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"[Item].[ItemByProducer].[ProducerName]").VisibleItemsList = Array( _
"[Item].[ItemByProducer].[ProducerName].&[the name of the producer]")
End Sub
The macro works well for that specific producer, but I want to create a variable of type string in which I can filter by other producers also.
How can I achieve that?
&
:"[Item].[ItemByProducer].[ProducerName].&[" & yourvariable & "]"
. – BigBen