This is related to solved question https://www.experts-exchange.com/questions/28962735/Make-sub-to-format-and-total-ranges.html
For convenience, I'm attaching the same .xlsx files.
I'd like to add bottom borders on the last 2 rows of each group as shown. I tried to change the code here but it just underlines the first cell of the 2nd row. I'd like to underline that whole row and the cells directly above that.
' Run after SeparateGroups
' Put BM's name on bolded line, and add bolded totals for each group.
' Also underline totals. It doesn't work correctly. Just 1 cell is underlined.
Dim rng As Range
Application.ScreenUpdating = False
For Each rng In Range("A:A").SpecialCells(xlCellTypeConstants, 2).Areas
If rng.Cells(1).Row <> 1 Then
rng.Cells(1).Copy rng.Cells(1).Offset(-1, 2)
With rng.Cells(1).Offset(-1, 2).Font
.Bold = True
.Size = 14
.Name = "Calibri"
rng.Cells(rng.Rows.Count + 1).Offset(0, 5).Resize(, 8).FormulaR1C1 = "=SUM(R[-" & rng.Rows.Count & "]C:R[-1]C)"
rng.Cells(rng.Rows.Count + 1).Offset(0, 5).Resize(, 8).Font.Bold = True
With rng.Cells(rng.Rows.Count + 1).Offset(0, 5).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
Application.ScreenUpdating = True
For my edification, I'd appreciate also an explanation of my error and how you fixed it. 8-)