I am using the below code to change the color of an entire row if certain words or phrases are found in a description field column C. These words or phases may appear anywhere within the string but always in column C
The code is working, but I know there must a way to make it more efficient.. I am repeating the same code over and over ,just substituting the find text word or phrase each time. The first Sub will call the next and so on. I would like to have one procedure that would accomplish the same thing.
Sub Red()
With ActiveSheet.Range("c:c")
Set c = .Find("DOOR HELD OPEN", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
'C.Interior.Pattern = xlPatternGray50
c.EntireRow.Select
Selection.Interior.ColorIndex = 3
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
Call Green
End Sub
Sub Green()
With ActiveSheet.Range("c:c")
Set c = .Find("RESTORED", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
'C.Interior.Pattern = xlPatternGray50
c.EntireRow.Select
Selection.Interior.ColorIndex = 4
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
Call Puple
End Sub
Thanks
L
The code is working, but I know there must a way to make it more efficient.. I am repeating the same code over and over ,just substituting the find text word or phrase each time. The first Sub will call the next and so on. I would like to have one procedure that would accomplish the same thing.
Sub Red()
With ActiveSheet.Range("c:c")
Set c = .Find("DOOR HELD OPEN", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
'C.Interior.Pattern = xlPatternGray50
c.EntireRow.Select
Selection.Interior.ColorIndex = 3
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
Call Green
End Sub
Sub Green()
With ActiveSheet.Range("c:c")
Set c = .Find("RESTORED", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
'C.Interior.Pattern = xlPatternGray50
c.EntireRow.Select
Selection.Interior.ColorIndex = 4
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
Call Puple
End Sub
Thanks
L
Code: