(Solved) – Performing range(array(x)) on an entire array instead of going element-by-element


I’m writing a macro that will take a changing list of numbers (placed in an array), copy the equivalent slides from a powerpoint, and then paste the selected slides into another powerpoint (so if the numbers are 2, 5, and 7, the macro will copy/paste powerpoint slides 2, 5, and 7). I can make it work with individual array elements, but can’t figure out how to pass all array elements at once into the selection. These are the relevant lines of code:

Dim NumberList() As Variant
NumberList= Range("A11", Range("A10").End(xlDown))
OriginalPowerpoint.Slides.Range(Array(NumberList(1, 1), NumberList(3, 1))).Copy
      'this is the line I'm having trouble with
NewPowerpoint.Slides.Paste -1

The above code does work, but I want to pass the entire NumberList into Array() in the third line, as opposed to the current samples of NumberList(1,1) and NumberList(3,1). Just putting in “NumberList” or “NumberList()” doesn’t work, and I’d really like to avoid making this a loop for efficiency reasons. Any advice would be greatly appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *