Sum several tabs

GCLIFTON

Board Regular
Joined
Feb 11, 2016
Messages
60
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:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top