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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,225,730
Messages
6,186,701
Members
453,369
Latest member
positivemind

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