title: Powerpoint VBA Select a Range of Slides
body: <p>While there are many responses on how to set a range if you know the Indexes/Names, what I need is a way to select a range of slides without specifying each slide index or name.  </p>
  
  <p>I have a slide called "C2 Title" at the start of a section and a slide called "C2Approval" at the end of a section.  The amount of slides between the two will vary depending on if users add slides in the middle. I want to select all the slides in between the two regardless of how many slides are inserted.</p>
  
  <p>I suspect there is a way to loop through the indexes to populate the array but I cannot seem to figure out how to do that.  </p>
  
  <p>UPDATE: Per request below here is what I've tried</p>
  
  <pre><code>Sub SelectSection()
  Dim sIndex As Long
  Dim eIndex As Long
  Dim sArray() As Long
  Dim sSlides As SlideRange
  
  
  ActivePresentation.Slides("C2Title").Select
  sIndex = ActiveWindow.Selection.SlideRange.SlideIndex
  
  ActivePresentation.Slides("C2DirectionalApproval").Select
  eIndex = ActiveWindow.Selection.SlideRange.SlideIndex
  
  'This solution only gets the first/last slide of range
  Set sSlides = ActivePresentation.Slides.Range(Array(eIndex - 1, sIndex + 1))
  
  'Problem is this assumes I've already selected Slides
  sSlides = ActiveWindow.Selection.SlideRange
   ReDim myArray(1 To sSlides.count)
        For y = LBound(sArray) To UBound(myArray)
          sArray(y) = Slides(y).SlideIndex
        Next y
  
  
  
  End Sub
  </code></pre>