答案1
您可以使用这样的 VBA 代码 - 它会影响当前选择(如果选择的是单元格范围
Option Explicit
Public Sub setBorders()
Dim cel As Range, clr1 As Long, clr2 As Long
clr1 = vbWhite 'if cell border color is different than white, and has LineStyle
clr2 = vbRed 'change its color to vbRed
If TypeOf Selection Is Range Then
For Each cel In Selection 'select your Range
With cel
With .Borders(xlEdgeLeft)
If .Color <> clr1 And .LineStyle <> xlNone Then .Color = clr2
End With
With .Borders(xlEdgeTop)
If .Color <> clr1 And .LineStyle <> xlNone Then .Color = clr2
End With
With .Borders(xlEdgeBottom)
If .Color <> clr1 And .LineStyle <> xlNone Then .Color = clr2
End With
With .Borders(xlEdgeRight)
If .Color <> clr1 And .LineStyle <> xlNone Then .Color = clr2
End With
End With
Next
End If
End Sub
要使用它,请打开 VBA 编辑器 -Alt + F11,并将代码粘贴到标准 VBA 模块中