Этот код использует Find
, чтобы быстро очистить ячейки, соответствующие желаемому формату
Строка для обновления для других полей ячейки:
.FindFormat.Interior.Color = Excel.XlRgbColor.rgbOrange
Option Explicit
Sub FastFind()
Dim rng1 As Range
Dim rng2 As Range
Dim cel1 As Range
Dim strFirstAddress As String
Dim lAppCalc As Long
'Get working range from user
On Error Resume Next
Set rng1 = Application.InputBox("Please select range to search for ", "User range selection", Selection.Address(0, 0), , , , , 8)
On Error GoTo 0
If rng1 Is Nothing Then Exit Sub
With Application
lAppCalc = .Calculation
.ScreenUpdating = False
.Calculation = xlCalculationManual
.FindFormat.Interior.Color = Excel.XlRgbColor.rgbOrange
End With
Set cel1 = rng1.Find("", , xlValues, xlPart, xlByRows, , , , True)
If Not cel1 Is Nothing Then
Set rng2 = cel1
strFirstAddress = cel1.Address
Do
Set cel1 = rng1.Find("", cel1, xlValues, xlPart, xlByRows, , , , True)
Set rng2 = Union(rng2, cel1)
Loop While strFirstAddress <> cel1.Address
End If
If Not rng2 Is Nothing Then rng2.Clear
With Application
.ScreenUpdating = True
.Calculation = lAppCalc
End With
End Sub