Add to a range array

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,600
Office Version
  1. 365
Platform
  1. Windows
I am wanting to use the following to specify specific default sheets and range that I want to copy to PowerPoint
Code:
MyRangeArray = Array(Sheet1.Range("A1:C10"), Sheet4.Range("A1:C10"),  Sheet3.Range("A1:C10"), Sheet2.Range("A1:C10"), Sheet5.Range("A1:C10"))

It may be that the number of sheets will increase dependent on what the suers selects but how do I add to this range?


TIA
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Look at the ReDim statement with the Preserve option.
I am wanting to use the following to specify specific default sheets and range that I want to copy to PowerPoint
Code:
MyRangeArray = Array(Sheet1.Range("A1:C10"), Sheet4.Range("A1:C10"),  Sheet3.Range("A1:C10"), Sheet2.Range("A1:C10"), Sheet5.Range("A1:C10"))

It may be that the number of sheets will increase dependent on what the suers selects but how do I add to this range?


TIA
 
Upvote 0
Is this what you need?
Code:
Dim MyRangeArray() As Variant
MyRangeArray = Array(Sheet1.Range("A1:C10"), Sheet2.Range("A1:C10"), Sheet3.Range("A1:C10"), Sheet4.Range("A1:C10"), Sheet5.Range("A1:C10"))
ReDim Preserve MyRangeArray(LBound(MyRangeArray) To UBound(MyRangeArray) + 1)
Set MyRangeArray(UBound(MyRangeArray)) = Sheet6.Range("A1:C10")
 
Upvote 0

Forum statistics

Threads
1,215,528
Messages
6,125,338
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top