ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using an array in Consolidation (https://www.excelbanter.com/excel-programming/299438-using-array-consolidation.html)

Steph[_3_]

Using an array in Consolidation
 
Hello everyone. I was hoping you could help with a relatively simple
problem. I am using the consolidation function in VBA, and have the
following code:

' Forecast.Select
' Range("B5").Select
' Selection.Consolidate Sources:=Array( _
' "'Sheet1'!R1C2:R10000C17" _
' , "'Sheet3'!R1C2:R10000C17" _
' , "'Sheet5'!R1C2:R10000C17" _
' , "'Sheet7'!R1C2:R1000C17" _
' ), Function:=xlSum, TopRow:=True, LeftColumn:=True,
CreateLinks:=False

I have already created an array for the sheets:
Set shtarray = Sheets(Array("Sheet1", "Sheet3", "Sheet5", "Sheet7"))

How do I use the shtarray variable in the consolidation statement so I
don't have to rename each sheet again? Thannks so much!!

-Steph


All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com