ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help data consolidation multiple workbooks (https://www.excelbanter.com/excel-programming/278201-need-help-data-consolidation-multiple-workbooks.html)

Chuck Harkes[_2_]

Need help data consolidation multiple workbooks
 
Tom Ogilvy was gracious enough to post the following piece of code
which I can modify to do pretty much what I want. However, I would
prefer to actually open each workbook using the "getopenfilename
multiselect=true method" as I need to perform some other actions on
the files before consolidating them. Since I haven't dealt much with
arrays I'm a bit confused about how to modify the pieces of code that
have to do with the array. Following is the piece of code. Would
appreciate any input. Thank you!:

Sub Totals()
Const MAXBOOK As Long = 20
Dim i%, SheetArg$()
Dim sPath1 As String
ReDim SheetArg(1 To MAXBOOK)


Dim sPath As String, sFile As String
ThisWorkbook.Worksheets("SumTotal") _
.Cells.ClearContents
sPath = "D:\Timelist\Data\"
i = 0
sPath1 = "D:\TimeList\Data\*.xls"
sFile = Dir(sPath1)
Do While sFile < ""
i = i + 1
SheetArg(i) = "'" & sPath & _
"[" & sFile & "]Total'!R1C2:R16384C3"

sFile = Dir()
Loop
' For i = 1 To MAXBOOK
' Debug.Print i, SheetArg(i)
' Next

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

End Sub


All times are GMT +1. The time now is 06:26 AM.

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