I'm new to VBA and I have a spreadsheet where I am trying to format the text to right align if the value in the cell equals "Total For The Month: ". I just need it to work for Worksheet1 in the workbook. If the value in cell C3 changes, I want the code to look through all the cells in column B and find any that equal "Total For The Month: " and right align it. However, my code isn't working. When I modify cell C3, nothing happens.
My code is as follows:
Dim SrchRng As Range, cel As Range
Set SrchRng = Range("$B1:$B1000")
If Target.Address = "C3" Then
For Each WS In Worksheets
With WS
For Each cel In SrchRng
If InStr(1, cel.Value, "Total For The Month: ") > 0 Then
cel.HorizontalAlignment = xlRight
End If
Next cel
End With
Next WS
End If
End Sub