我的代码给出了我的类型不匹配。
我不知道为什么,因为 cf 是 FormatCondition 类型
Sub ClearBottomBorderConditionalFormatting()
Dim ws As Worksheet
Dim cf As FormatCondition
Set ws = ThisWorkbook.Sheets("Sheet1")
For Each cf In ws.Cells.FormatConditions
If cf.Borders(xlBottom).LineStyle <> xlNone Then
cf.Delete
End If
Next cf
End Sub
Sub ClearBottomBorderConditionalFormatting()
Dim ws As Worksheet
Dim rng As Range
Dim cf As FormatCondition
Dim i As Long
Set ws = ThisWorkbook.Sheets("Sheet1")
Set rng = ws.UsedRange
For i = rng.FormatConditions.Count To 1 Step -1
Set cf = rng.FormatConditions(i)
If cf.Type = xlCellValue And cf.Borders(xlBottom).LineStyle <> xlNone Then
cf.Delete
End If
Next i
End Sub
问题可能与范围的设置方式有关。您可以尝试一下我上面提供的代码吗?如果不起作用,请告诉我。