LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Len Len is offline
external usenet poster
 
Posts: 162
Default Dynamic Array for data consolidation

Hi,

After I made use the codes from the same thread, modified for my need
and later I found out that I do not know how to change the codes below
from hard code array to dynamic array to take any number of excel
workbooks ( ie it will increase from time to time ) from a folder and
later to run data consolidation

Sub DataConsol()

Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual


Const MAXBOOK As Long = 5
Dim i%, SheetArg$()
Dim sPath1 As String
ReDim SheetArg(1 To MAXBOOK)
Dim sPath As String, sFile As String

Windows("Data Consol.xls").Activate
ThisWorkbook.Worksheets("Sum").Cells.ClearContents
sPath = "C:\Bgt\AF\BA\mic4\"
i = 0
sPath1 = "C:\Bgt\AF\BA\mic4\*.xls"
sFile = Dir(sPath1, vbNormal)
Do While sFile < ""
i = i + 1
SheetArg(i) = "'" & sPath & "[" & sFile & "]P+L'!R6C2:R47C15 "
sFile = Dir()
Loop


ThisWorkbook.Sheets("Sum").Range("A1").Consolidate _
Sources:=Array(SheetArg), Function:=xlSum, TopRow:=True, _
LeftColumn:=True, CreateLinks:=True

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True


End Sub

Any helps on the above will be appreciated as I'm beginner to excel
vba

Thanks & Regards
Len
 
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
array transpose for dynamic data without macros Rad131304 Excel Discussion (Misc queries) 7 February 18th 10 10:48 PM
Data Consolidation using dynamic path Jholerjo Excel Programming 1 December 17th 07 12:03 PM
Consolidation Array Help QuietMan Excel Programming 0 October 11th 06 12:06 AM
Consolidation Array QuietMan Excel Programming 0 October 11th 06 12:04 AM
Using an array in Consolidation Steph[_3_] Excel Programming 0 May 25th 04 05:54 PM


All times are GMT +1. The time now is 08:36 PM.

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

About Us

"It's about Microsoft Excel"