I3atnumb3rs
New Member
- Joined
- Nov 2, 2018
- Messages
- 34
Hello,
I'm trying to have my code figure out how many worksheets there are and to loop through each one to calculate and place the sum of column F in the first blank row in column F in each worksheet. My code is only partly working. Please Help!
Sub WorksheetLoop()
Dim lastRowInColA As Integer
Dim totPointsRow As Integer
Dim columnSum As Double
Dim LastRowNum As Long
Dim WS_Count As Integer
' Set WS_Count equal to the number of worksheets in the active
' workbook.
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop through all sheets
For i = 1 To WS_Count
With ActiveWorkbook.Worksheets(i).Range("F" & Rows.Count).End(xlUp).Select
lastRowInColA = Selection.Row
totPointsRow = lastRowInColA + 1
Range("E" & totPointsRow) = "Total:"
Range("F" & totPointsRow) = Application.WorksheetFunction.Sum(Columns("F:F"))
End With
Next i
End Sub
I'm trying to have my code figure out how many worksheets there are and to loop through each one to calculate and place the sum of column F in the first blank row in column F in each worksheet. My code is only partly working. Please Help!
Sub WorksheetLoop()
Dim lastRowInColA As Integer
Dim totPointsRow As Integer
Dim columnSum As Double
Dim LastRowNum As Long
Dim WS_Count As Integer
' Set WS_Count equal to the number of worksheets in the active
' workbook.
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop through all sheets
For i = 1 To WS_Count
With ActiveWorkbook.Worksheets(i).Range("F" & Rows.Count).End(xlUp).Select
lastRowInColA = Selection.Row
totPointsRow = lastRowInColA + 1
Range("E" & totPointsRow) = "Total:"
Range("F" & totPointsRow) = Application.WorksheetFunction.Sum(Columns("F:F"))
End With
Next i
End Sub