Okay so I'm fairly new to VBA but I've managed to to get this to partially work. I'm trying to make this sum the Columns and Bold the totals at the bottom of the Column based on the headers which will always be in the first row and start at Column M. I just don't know how to get it to search through the other headers it always stop after summing the first Column. I'm not sure if it has something to do with not making my sum formula variable instead of setting it at Column M.
I've also included the ActiveWorkbook.Sheets line because I plan to eventually alter it to also repeat this process on a Sheet named Sheet2 after completing Sheet1 but I'm not sure if this line is the way to do it.
Sub Totals()
Dim end_row_M As Long
end_row_M = Range("M65536").End(xlUp).Row
Target = "Criteria 1"
Target2 = "Criteria 2"
Target3 = "Criteria 3"
Range("M1").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = Target Or ActiveCell.Value = Target2 Then
ActiveWorkbook.Sheets("Sheet1").Range("M" & end_row_M + 1).Formula = "=SUM(M2:M" & end_row_M & ")"
ActiveWorkbook.Sheets("Sheet1").Range("M" & end_row_M + 1).Font.Bold = True And ActiveCell.Offset(0, 1).Activate
Else
ActiveCell.Offset(0, 1).Activate
End If
Loop
End Sub
Bookmarks