I'm trying to sum several individual cells from several Workbooks into one Workbook. I need it to be in VBA because using Consolidate Data doesn't seem to work with text (creates blank cells) and using =SUM([48800.xlsm]Summary!H5,[49900.xlsm]Summary!H5) doesn't work that well with several hundred Workbooks.
I'm trying to find a VBA code that will loop through one folder with any Workbooks named *.xls or *.xlsm and grab several specific cells (ex. H5, I5, J5, H6, I6, J6) from (Sheet: Summary) and sum each cell to one Workbook with (Sheet: Summary) to the same cell locations (H5, I5, J5, H6, I6, J6) because it will have the same layout.
I found this code, but I don't know much about VBA to modify it to my needs. I will truly appreciate anyone's help and time.
-------------------------------------
I use Windows 7 64-bit and Excel 2007
I'm trying to find a VBA code that will loop through one folder with any Workbooks named *.xls or *.xlsm and grab several specific cells (ex. H5, I5, J5, H6, I6, J6) from (Sheet: Summary) and sum each cell to one Workbook with (Sheet: Summary) to the same cell locations (H5, I5, J5, H6, I6, J6) because it will have the same layout.
I found this code, but I don't know much about VBA to modify it to my needs. I will truly appreciate anyone's help and time.
Code:
Sub total()
Dim a As Integer, x As Integer
Dim f As String
Cells(2, 1).Select
f = Dir("d:\test\" & "*.xls")
Do While Len(f) > 0
ActiveCell.Formula = f
ActiveCell.Offset(1, 0).Select
f = Dir()
Loop
Cells(1, 2) = ""
x = Cells(Rows.Count, 1).End(xlUp).Row
For a = 2 To x
Cells(1, 1) = "='d:\test\[" & Cells(a, 1) & "]Summary'!B7"
Cells(1, 2) = Cells(1, 2) + Cells(1, 1)
Next a
MsgBox " The total of B7 from " & x - 1 & " files is " & Cells(1, 2)
End Sub
-------------------------------------
I use Windows 7 64-bit and Excel 2007
Last edited: