Just another way of doing things making use of FindFormat
and ReplaceFormat
properties.
Sub BordersReplace()
With ThisWorkbook.Sheets(1)
For X = xlEdgeLeft To xlEdgeRight
With Application.FindFormat.Borders(X)
.Color = 0
End With
With Application.ReplaceFormat.Borders(X)
.Color = 255
End With
.Cells.Replace What:="", Replacement:="", searchformat:=True, ReplaceFormat:=True
Application.FindFormat.Clear
Application.ReplaceFormat.Clear
Next X
End With
End Sub
Small loop involved to go through the appropriate XLBordersIndex
enumeration.
Note, not clearing FindFormat
and ReplaceFormat
will make Excel keep working with the first used format, hence why the .Clear
is nesseccary.
I myself am a little bit puzzled on why it would't work on the cells with all edges on its borders applied. For that to work use Application.FindFormat.Borders()
UsedRange
like in the answer below. - Mikku