Add to a range array

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,564
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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

tusharm

MrExcel MVP
Joined
May 28, 2002
Messages
11,029
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

Tetra201

MrExcel MVP
Joined
Oct 14, 2016
Messages
3,801
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,190,911
Messages
5,983,524
Members
439,848
Latest member
timmyo

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
Top