Hello,
Basically what is happening with my code is I create many worksheets which have a dollar amounts
in column C of each worksheet. The code sums the column C in the first worksheet - e.g. sum of column C is 15 for worksheet 1 - and it will display a message box with total 15, it then sums the column C of the second worksheet - e.g. sum of column C is 10 for worksheet 2 - it then displays a message bow which is worksheet 1 (15) + worksheet 2 (10) and displays a second msgbox of (25), I would like the msgboxs to display the sum of column C of each worksheets separately, not summing them together. Any questions please feel free. I greatly appreciate any assistance.
Here is the code:
Sub Step1()
Dim ws As Worksheet
Dim LastRow As Integer
Dim Myrange As Range
Dim Total As Double
For Each ws In ThisWorkbook.Worksheets
Sheets(ws.Name).Select
LastRow = Range("C" & Rows.Count).End(xlUp).Row
Set Myrange = Range("1:" & LastRow)
Total = Total + WorksheetFunction.Sum(Myrange)
MsgBox "Total For " & ws.Name & " " & Total & "" 'This works but still adds all sheets need single ofr each sheet
Next ws
End Sub
Basically what is happening with my code is I create many worksheets which have a dollar amounts
in column C of each worksheet. The code sums the column C in the first worksheet - e.g. sum of column C is 15 for worksheet 1 - and it will display a message box with total 15, it then sums the column C of the second worksheet - e.g. sum of column C is 10 for worksheet 2 - it then displays a message bow which is worksheet 1 (15) + worksheet 2 (10) and displays a second msgbox of (25), I would like the msgboxs to display the sum of column C of each worksheets separately, not summing them together. Any questions please feel free. I greatly appreciate any assistance.
Here is the code:
Sub Step1()
Dim ws As Worksheet
Dim LastRow As Integer
Dim Myrange As Range
Dim Total As Double
For Each ws In ThisWorkbook.Worksheets
Sheets(ws.Name).Select
LastRow = Range("C" & Rows.Count).End(xlUp).Row
Set Myrange = Range("1:" & LastRow)
Total = Total + WorksheetFunction.Sum(Myrange)
MsgBox "Total For " & ws.Name & " " & Total & "" 'This works but still adds all sheets need single ofr each sheet
Next ws
End Sub