S
Slim Slender
The following procedure places borders conditionally as I want but it
does not stop when the Until condition is met. Instead it continues,
apparently to the bottom of the sheet, then gives an Error 400 which
is no help.
I think the problem is Range("C:C") but I don't know how to fix it.
Also, I would like to precede this in the same procedure with
something that would remove any existing borders. Any help would be
appreciated.
Public Sub DrawBorders()
Dim cell As Range
Dim numRows As Single
numRows = Selection.CurrentRegion.Rows.Count
Do
For Each cell In Range("C:C")
If cell.Offset(1, 0).Value <> cell.Value Then
With Range(Cells(cell.Row, 1), Cells(cell.Row,
5)).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 1
End With
Else
End If
Next cell
Loop Until cell.Row = numRows
End Sub
does not stop when the Until condition is met. Instead it continues,
apparently to the bottom of the sheet, then gives an Error 400 which
is no help.
I think the problem is Range("C:C") but I don't know how to fix it.
Also, I would like to precede this in the same procedure with
something that would remove any existing borders. Any help would be
appreciated.
Public Sub DrawBorders()
Dim cell As Range
Dim numRows As Single
numRows = Selection.CurrentRegion.Rows.Count
Do
For Each cell In Range("C:C")
If cell.Offset(1, 0).Value <> cell.Value Then
With Range(Cells(cell.Row, 1), Cells(cell.Row,
5)).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 1
End With
Else
End If
Next cell
Loop Until cell.Row = numRows
End Sub