Jun 26 2022 11:47 AM - edited Jun 26 2022 12:19 PM
Hello Everyone,
When we run the loop multiple time, its adding up and filling the next cells down. what function to be given to to get the sum value which sticks to single cell ?
Please help...
Here is a attached file..
Jun 26 2022 12:34 PM
SolutionSub AutomateSum()
Dim lastrow As String
Dim ws As Worksheet
For Each ws In Worksheets
Worksheets(ws.Name).Select
Range("E2").Select
Selection.End(xlDown).Select
lastrow = ActiveCell.Row
ActiveCell.Offset(1, 1).Select
ActiveCell.Value = "=sum(F2:F" & lastrow & ")"
Next ws
End Sub
You can try the attached file with these lines of code.
Jun 26 2022 12:34 PM
SolutionSub AutomateSum()
Dim lastrow As String
Dim ws As Worksheet
For Each ws In Worksheets
Worksheets(ws.Name).Select
Range("E2").Select
Selection.End(xlDown).Select
lastrow = ActiveCell.Row
ActiveCell.Offset(1, 1).Select
ActiveCell.Value = "=sum(F2:F" & lastrow & ")"
Next ws
End Sub
You can try the attached file with these lines of code.