title: Setting a slicer to the value of a variable using VBA macro (Excel)
body: <p>This is a very trivial question for the experts out here :)</p>
  
  <p>I'm trying to set a slicer to the value of a variable using a macro. I've declared a String variable.</p>
  
  <pre><code>Dim ProductName As String
  '+Some code here to assign a value to ProductName (value of a cell)
  ActiveWorkbook.SlicerCaches("Slicer_Name1").VisibleSlicerItemsList = Array( _
              "[Team Project].[Project Node Name].&amp;[ProductName]")
  </code></pre>
  
  <p>That obviously does not work and I didn't expect it to but I can't figure out how I can have it treat ProductName as a variable and not a literal.</p>
  
  <p>The rest of the code is fine as I can successfully set the slicer by specifying a product name without using a variable.</p>
  
  <pre><code>ActiveWorkbook.SlicerCaches("Slicer_Name1").VisibleSlicerItemsList = Array( _
              "[Team Project].[Project Node Name].&amp;[Bedsheets]")
  </code></pre>