VBA code for find keyword in column E if found, change font color in matching B column cell

tkbaty

New Member
Joined
Oct 17, 2019
Messages
1
Hi newbie Excel macros and VBA user here...

I need either macro or VBA code to do the following:

find keyword (not case sensitive) in column E which contains various text notes.
if found, change font color in matching B column cell
Then repeat for all cells in column to final row.
Note I have 3 sections of rows in the spread that are separated by blank rows for subtotalling.

Note2: I actually have two keywords ("died" and "d/c") that I need to find then colorcode the B col cell font
different colors. Bold Blue for died. And bold green for d/c.

I think I should be able to do with a loop or If, Elseif type vba code...but can't figure how to write it.

Would so appreciate any help.

Thanks!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi & welcome to MrExcel.
How about
Code:
Sub tkbaty()
    With ActiveSheet
        .Range("A1:E1").AutoFilter 5, "*died*"
        With .AutoFilter.Range.Offset(1).Columns(2).Font
            .Bold = True
            .Color = vbBlue
        End With
        .Range("A1:E1").AutoFilter 5, "*d/c*"
        With .AutoFilter.Range.Offset(1).Columns(2).Font
            .Bold = True
            .Color = vbGreen
        End With
        .AutoFilterMode = False
    End With
End Sub
 
Upvote 0
Code:
Option Explicit
Option Compare Text


Sub tkbaty()
    Dim i As Long, lr As Long
    lr = Range("E" & Rows.Count).End(xlUp).Row
    Application.ScreenUpdating = False
    For i = 1 To lr
        If Range("E" & i) = "died" Then
            Range("B" & i).Font.Color = vbBlue
            Range("B" & i).Font.Bold
        ElseIf Range("E" & i) = "d/c" Then
            Range("B" & i).Font.Color = vbGreen
            Range("B" & i).Font.Bold
        End If
    Next i
    Application.ScreenUpdating = True
    MsgBox "complete"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top