View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Steph[_3_] Steph[_3_] is offline
external usenet poster
 
Posts: 312
Default 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