Get Last Row Value to a Row from closed workbook

arijitirf

Board Regular
Joined
Aug 11, 2016
Messages
118
Office Version
  1. 2016
Platform
  1. Windows
Hi!!!

I need to break my original excel file into 6 different workbooks due to it's size. Now, I want to put the total values of last row for each sheet of that 6 workbooks to 6 different cell in a new excel workbook without opening it. Actually I want to create a macro so that it show me the total value of the last row of each sheet of that 6 workbooks whenever I open the new Workbook namely "Control.xlsx"


Public Sub SumLastRows()

Dim total As Long
Dim ws As Worksheet
Dim lastRow As Long

total = 0
For Each ws In ActiveWorkbook.Worksheets
lastRow = ws.Cells(ws.Rows.Count, "J").End(xlUp).Row
If IsNumeric(ws.Cells(lastRow, "J").Value) Then
total = total + ws.Cells(lastRow, "J").Value
Else
Debug.Print "Cell J" & CStr(lastRow) & " on sheet '" & ws.Name & "' is not numeric"
End If
Next

MsgBox "Total is : " & CStr(total), vbOKOnly + vbInformation, "Sum Last Rows"

End Sub
above code was written by wideboydixon, which I want to use for that 6 workbooks and get result into "Control.xlsx"

Help Required.
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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