Hello, I am trying to update a macro that someone else wrote and I cannot follow the logic. Currently this macro will total/format cells within defined sections of rows between columns I and O.
However, we have added a column and now we need the macro to change to do columns J to P instead. We would also like to EXCLUDE just row 2. Nothing else needs to change. Can anyone help? Here is the code -
However, we have added a column and now we need the macro to change to do columns J to P instead. We would also like to EXCLUDE just row 2. Nothing else needs to change. Can anyone help? Here is the code -
VBA Code:
Sub Totals()
Dim i As Long
Dim lrow As Long
Dim PrevRow As Long
Dim j As Long
lrow = Cells(Rows.Count, 1).End(xlUp).Row
PrevRow = 1
For i = 2 To lrow + 1
If Cells(i, 1) = "" Then
Range("I" & i) = "=Sum(I" & PrevRow + 1 & ":I" & i - 1 & ")"
Range("I" & i).Copy
Range("J" & i & ":O" & i).PasteSpecial xlPasteFormulas
Application.CutCopyMode = False
PrevRow = i
Range("I" & i & ":O" & i).Font.Color = 0
Range("I" & i & ":O" & i).Font.Bold = True
For j = 9 To 15
If Cells(i, j) < 50000 Then Cells(i, j).Font.Color = -11489280 'Turn everything < 50k to green font
If Cells(i, j) > 75000 Then Cells(i, j).Font.Color = -16776961 'Turn everything > 75k to red font
Next j
End If
Next i
End Sub
Last edited by a moderator: