Nelson78
Well-known Member
- Joined
- Sep 11, 2017
- Messages
- 526
- Office Version
- 2007
Hello everybody.
I've to match a string - cellz - in a range of cells.
The task is ok like this:
As you can see, I'm able of highlighting the cells where the string is found:
But I need something more: I need to write in yellow characters the string when found.
I mean: imagine cellz = "Paris"
Imagine cell where I'm looking for = "I don't live in Paris but I live in London"
I need like this: "I don't live in Paris but I live in London"
How can I perform the task?
I've to match a string - cellz - in a range of cells.
The task is ok like this:
VBA Code:
Dim cellz As Variant
For Each cellz In sheet1.Range("A2:A" & lr_col)
With CreateObject("VBScript.RegExp")
.Global = True
.IgnoreCase = True
.Pattern = "\b" & cellz & "\b"
For Each r In sheet2.Range("AG2:AG" & lr_ris)
If .test(r.Value) Then r.Interior.Color = vbRed
Next r
End With
Next cellz
As you can see, I'm able of highlighting the cells where the string is found:
Code:
If .test(r.Value) Then r.Interior.Color = vbRed
But I need something more: I need to write in yellow characters the string when found.
I mean: imagine cellz = "Paris"
Imagine cell where I'm looking for = "I don't live in Paris but I live in London"
I need like this: "I don't live in Paris but I live in London"
How can I perform the task?
Last edited: