title: Excel VBA - Return selected element in slicer
body: <p>I have a slicer called 'Slicer_HeaderTitle'. I simply need to be able to dim a variable in VBA with the value of the selected element. I'll only have one element selected at a time. </p>
  
  <p>I've had a lot of problems with selecting and de-selecting elements from my slicer dynamically via VBA, since my pivot table is connected to an external data-source. I don't know if this is relevant for this exact example, but this table is connected to the same external data-source.</p>
  
  <p>I used to have a single line of code, which could return this value, but all i could find now requires you loop through each element in the slicer and check if it's selected or not. I hope to avoid this, since I only have 1 selected element at a time.</p>
  
  <p><a href="https://i.stack.imgur.com/66JrZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/66JrZ.png" alt="enter image description here"></a></p>
  
  <pre><code>' This is what I'm trying to achieve.
  Dim sValue as String
  sValue = ActiveWorkbook.SlicerCaches("Slicer_HeaderTitle").VisibleSlicerItems.Value
  
  msgbox(sValue)
  'Returns: "Uge 14 - 2016 (3. Apr - 9. Apr)"
  </code></pre>
  
  <hr>
  
  <p>Current Status:</p>
  
  <p><a href="https://i.stack.imgur.com/SLOX9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SLOX9.png" alt="enter image description here"></a></p>