i am trying to updated this VBA to now sum Column D and c start with D3 AND C3 in each spreadsheet that it opens and place the value in Column L AND M on the Sumarry_1 Tab. Currently it just copies the the second line in each sheet to the summary_1 tab inwhich i would like to keep. So basically we are adding L AND M that is the sum of C3:Last Row AND D3:Last Row
Code:
Sub openfILES()
Dim sh As Worksheet, wb As Workbook, lr As Long
Dim Source As String
Dim StrFile As String
expPath = Range("B5") 'pull export file path from cell B5
Set sh = ThisWorkbook.Sheets("Summary_1")
Source = expPath
StrFile = Dir(Source & "*.tab*")
Do While Len(StrFile) > 0
lr = sh.Cells.Find("*", , xlValues, xlPart, xlByRows, xlPrevious).Row
If StrFile <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(Source & StrFile)
If Application.CountA(wb.Sheets(1).Range("A2:K2")) > 0 Then
wb.Sheets(1).Range("A2:K2").Copy sh.Cells(lr + 1, 1)
wb.Close False
End If
End If
StrFile = Dir()
Loop
MsgBox "Done!"
End Sub
Last edited: