The code below merges a number of cells in column A and V. How would I also have it add a bottom border to the last row in each cell merge?
For instance, it may merge A3:A9 and V3:V9. I would want a bottom border added to A9 through V9. Also, how would I specify the color of the border?
Thanks
On Error GoTo safeExit
headerRow = 1
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
f = headerRow + 1
Application.DisplayAlerts = False
Do Until f > lastRow
l = f + 1
Do Until (Cells(l, 1) <> Cells(l - 1, 1)) Or (Cells(l, 22) <> Cells(l - 1, 22))
l = l + 1
Loop
If f <> l Then
For c = 1 To 22 Step 21
With Range(Cells(f, c), Cells(l - 1, c))
.merge
.VerticalAlignment = xlCenter
End With
Next c
End If
f = l
Loop
safeExit:
Application.DisplayAlerts = True
For instance, it may merge A3:A9 and V3:V9. I would want a bottom border added to A9 through V9. Also, how would I specify the color of the border?
Thanks
On Error GoTo safeExit
headerRow = 1
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
f = headerRow + 1
Application.DisplayAlerts = False
Do Until f > lastRow
l = f + 1
Do Until (Cells(l, 1) <> Cells(l - 1, 1)) Or (Cells(l, 22) <> Cells(l - 1, 22))
l = l + 1
Loop
If f <> l Then
For c = 1 To 22 Step 21
With Range(Cells(f, c), Cells(l - 1, c))
.merge
.VerticalAlignment = xlCenter
End With
Next c
End If
f = l
Loop
safeExit:
Application.DisplayAlerts = True