LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Consolidation Function VBA

Thanks Bill, I will try this
I'm new to using arrays, so cold be some issues

Wilkl let you know jow it goes

--
Helping Is always a good thing


"Bill Pfister" wrote:

Using an intermediate array-creating function should minimize code duplication:




Public Sub ConsolidationTest()
Dim strAreas2 As Variant
Dim wkb As Workbook

Set wkb = ThisWorkbook


' Use following line of code to specify how to create your intended array
' The 2nd param ("R3C1") is the source address
' The 3rd param (Array(1, 2, 3)) is the indices of the source sheets
Call CreateArray(wkb, "R3C1", Array(1, 2, 3), strAreas2)

wkb.Sheets(1).Range("A1").Consolidate Sources:=strAreas2, Function:=xlSum

End Sub


Public Sub CreateArray(wkb As Workbook, strArea As String, _
arrList As Variant, arrParam As Variant)
Dim strElement As String
Dim lngCount As Long
Dim i As Long

lngCount = UBound(arrList) - LBound(arrList)

ReDim arrParam(0 To lngCount) As String

For i = 0 To lngCount
strElement = "'" & wkb.Path & "\[" & wkb.Name & "]" & _
wkb.Worksheets(Int(arrList(i))).Name & "'!" & strArea
arrParam(i) = strElement
Next i

End Sub




"QuietMan" wrote:

Dose anyone know how to simplify this function??
I have to write the function 8 times (consolidation 8 seperate areas on a
spreadsheet) the only parts that change are the sheet numbers and the
consolidation area.

Example: all sheets consolidated for Q1, 3 sheets for Q2, ect....

I hoping to be able to have the array that's being created be dynamic based
on information located in a specified worksheet.

thanks in advance

Selection.Consolidate Sources:=Array( _
"'" & ThisWorkbook.Path & "\[" & ThisWorkbook.Name & "]" &
Sheet38.Name & "'!" & Q3_Area, _
"'" & ThisWorkbook.Path & "\[" & ThisWorkbook.Name & "]" &
Sheet36.Name & "'!" & Q3_Area, _
"'" & ThisWorkbook.Path & "\[" & ThisWorkbook.Name & "]" &
Sheet37.Name & "'!" & Q3_Area, _
"'" & ThisWorkbook.Path & "\[" & ThisWorkbook.Name & "]" &
Sheet34.Name & "'!" & Q3_Area, _
"'" & ThisWorkbook.Path & "\[" & ThisWorkbook.Name & "]" &
Sheet31.Name & "'!" & Q3_Area, _
"'" & ThisWorkbook.Path & "\[" & ThisWorkbook.Name & "]" &
Sheet35.Name & "'!" & Q3_Area, _
"'" & ThisWorkbook.Path & "\[" & ThisWorkbook.Name & "]" &
Sheet25.Name & "'!" & Q3_Area, _
"'" & ThisWorkbook.Path & "\[" & ThisWorkbook.Name & "]" &
Sheet28.Name & "'!" & Q3_Area), _
Function:=xlSum, TopRow:=False, LeftColumn:=False, CreateLinks:=False


--
Helping Is always a good thing

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Consolidation function QuietMan Excel Programming 2 October 3rd 06 01:35 AM
consolidation nance666 Excel Discussion (Misc queries) 1 August 26th 05 01:49 PM
Consolidation capnsean Excel Discussion (Misc queries) 3 July 8th 05 10:53 PM
Product Function in Pivot Tables from Multiple Consolidation Range bbishop222 Excel Worksheet Functions 0 February 22nd 05 04:55 PM
Consolidation teresa Excel Programming 0 December 29th 04 04:49 PM


All times are GMT +1. The time now is 06:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"