Macro to bold row when certain words are found

constantinet

New Member
Joined
Mar 9, 2017
Messages
16
Wondering if someone might be able to help with creating a macro.
I have various words in column A and when certain words are found I need the row bold when those words are found.
So for example when words teacher, student, or class are find in column A then I need the row those words are found on to be bold from A:G.

Thanks you in advance for any help.
 
Last edited:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
This code should work. (Note: The word in column A must have a capital first letter)

Code:
Sub BoldAtoG()


Dim LastRow As Long
LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row


For Each C In Range("A1:A" & LastRow).Cells
C.Select
If C.Value = "Teacher" Or C.Value = "Student" Or C.Value = "Class" Then
        C.Offset(0, 6).Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Selection.Font.Bold = True
    Else
    End If
    Next
End Sub
 
Upvote 0
Code:
Option Explicit


Sub BoldAG()
    Dim lr As Long, i As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    Application.ScreenUpdating = False
    For i = 1 To lr
        If InStr(Range("A" & i), "teacher") > 0 Then
            Range("A" & i & ":G" & i).Font.Bold = True
        ElseIf InStr(Range("A" & i), "student") > 0 Then
            Range("A" & i & ":G" & i).Font.Bold = True
        ElseIf InStr(Range("A" & i), "class") > 0 Then
            Range("A" & i & ":G" & i).Font.Bold = True
        End If
    Next i
    Application.ScreenUpdating = True
    MsgBox "Action Complete"


End Sub

You did not capitalize the criteria so I did not also.
 
Last edited:
Upvote 0
You can also do that with CF
Select cols A:G > Home Tab > Conditional Formatting > New rule > Use a formula > =OR($A1="Teacher",$A1="student",$A1="Class") > select the format > OK
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,637
Members
449,461
Latest member
kokoanutt

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