Notifications
Clear all
Topic starter
Hi guys,
I would like to highlight the cells I am replacing but the code does not work, can you see the fail?
Sub find_replace1()
Range("C2:AG126").replace what:="something", replacement:="Hey", MatchCase:=True
with replacement
.replacement.highlight=true
end with
End Sub
Posted : 16/05/2020 11:46 am
I dont think you can use the find/replace in that way as it only finds and replaces.
Pretty sure you will need to test each cell and then colour it in
This should would work
Sub find_replace1()
Dim r As Range
Dim C As Range
Set r = Range("C2:AG126")
For Each C In r
Debug.Print C.Address
If C.Value = "s" Then
C.Value = "Hey"
C.Interior.Color = vbYellow
End If
Next C
End Sub
Posted : 16/05/2020 1:59 pm