billandrew
Well-known Member
- Joined
- Mar 9, 2014
- Messages
- 743
Have been searching How to add worksheets if does not exist and then add totals to Column B. Not sure How to execute the top portion of the code.
thank you
thank you
Code:
Sub TotalEachWorksheet() Grandtotal = 0
Worksheets.Add
ActiveSheet.Name = "Summary"
Worksheets.Add
ActiveSheet.Name = "Code"
With ThisWorkbook
For i = 1 To .Sheets.Count
If .Sheets(i).Name = "Summary" Then
blnfound = True
Exit For
End If
Next i
End With
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "Summary" Or ws.Name <> "Code" Then
Total = ws.Cells(Rows.Count, 2).End(xlUp).Value
ThisSheet = ws.Name
Grandtotal = Grandtotal + Total
End If
Next ws
With Sheets("Summary")
.Cells(1, 2).Value = Grandtotal
.Cells(1, 1).Value = "GrandTotal"
.Cells(1, 1).Font.Bold = True
.Cells(1, 1).Select
End With
End Sub