Hey,
I'm trying to get the value (text) from one cell (works) and then find all other matching cells in the document and highlight them with color.
The first part until Next MyCell works perfectly, my problem is that this code wouldn't find the word f.e. "After" if I'd search for "Aft" or "after".
So I tried to do another one (from Dim ws As Worksheet until end) but somehow I cant get it to work.
"Search_For_Word" stands for cell J4 and I renamed that one so its fixed.
Im using Excel 2016, Windows 11 x64
I hope someone has ideas!
I'm trying to get the value (text) from one cell (works) and then find all other matching cells in the document and highlight them with color.
The first part until Next MyCell works perfectly, my problem is that this code wouldn't find the word f.e. "After" if I'd search for "Aft" or "after".
So I tried to do another one (from Dim ws As Worksheet until end) but somehow I cant get it to work.
"Search_For_Word" stands for cell J4 and I renamed that one so its fixed.
Im using Excel 2016, Windows 11 x64
I hope someone has ideas!
VBA Code:
Sub Color_Cell_From_Value_Of_Cell()
Dim CellValue As String
CellValue = Range("Search_For_Word").Value
Dim MyCell As Range
Dim StatValue As String
Dim StatusRange As Range
Set StatusRange = Range("Status")
For Each MyCell In StatusRange
StatValue = MyCell.Value
Select Case StatValue
Case CellValue
MyCell.Interior.Color = RGB(255, 255, 0)
End Select
Next MyCell
Dim ws As Worksheet
Set ws = Worksheets("Tabelle1")
If ws.Range("Search_For_Word") = Application.WorksheetFunction.Search(CellValue, ws.Range("A1:G119")) Then
Range("Status").Interior.Color = RGB(255, 255, 0)
End If
End Sub