Hi,
I have done the following coding for you.
Assumption:
A2 should alway contain "Internal"
Sub format_it()
Range("A2:E4").Interior.ColorIndex = 15
Dim r As Long
r = 5
Do While Cells(r, 1) <> "INT Total"
r = r + 1
Loop
r = r - 1
If r >= 6 Then
Range("b5", Cells(r, 5)).Select
With Selection
.BorderAround Weight:=xlMedium
.Borders(xlInsideVertical).LineStyle = xlDot
.Borders(xlInsideHorizontal).LineStyle = xlDot
End With
End If
Dim r2 As Long
r2 = r + 5
Range(Cells(r + 1, 1), Cells(r + 6, 5)).Interior.ColorIndex = 15
Do While Cells(r2, 1) <> "EXT Total"
r2 = r2 + 1
Loop
r2 = r2 - 1
Range(Cells(r + 7, 2), Cells(r2, 5)).Select
With Selection
.BorderAround Weight:=xlMedium
.Borders(xlInsideVertical).LineStyle = xlDot
.Borders(xlInsideHorizontal).LineStyle = xlDot
End With
Range(Cells(r2 + 1, 1), Cells(r2 + 1, 5)).Interior.ColorIndex = 15
Range(Cells(r2 + 2, 1), Cells(r2 + 2, 5)).Interior.ColorIndex = 45
End Sub
Bookmarks