Dannottheman
Board Regular
- Joined
- Dec 24, 2020
- Messages
- 55
- Office Version
- 2007
Hello,
I am currently using the VBA below which has been working great until now. The script is supposed to find and shading rows containing certain words but now it's shading incorrect rows. For example, it's supposed to shade a cell containing the word "test", but if the cell has the word "testicle", it should NOT shade the cell. Right now it's shading cells because some characters match the word (e.g. unit vs united). Can someone please modify the VBA below so that it only considers the whole word/exact match?
Option Explicit
Sub Dannottheman3()
Dim Cl As Range
Dim srch As Variant
For Each Cl In Range("A1", Range("A" & Rows.Count).End(xlUp))
For Each srch In Array("*quiz*", "*unit*", "*exam*", "*assessment*", "*test*") ' <= note the different use of the jolly (could be useful)
If LCase(Cl.Value) Like srch Then
Cl.Interior.Color = rgbLightBlue
Cl.Font.Bold = True
Exit For
End If
Next srch
Next Cl
End Sub
I am currently using the VBA below which has been working great until now. The script is supposed to find and shading rows containing certain words but now it's shading incorrect rows. For example, it's supposed to shade a cell containing the word "test", but if the cell has the word "testicle", it should NOT shade the cell. Right now it's shading cells because some characters match the word (e.g. unit vs united). Can someone please modify the VBA below so that it only considers the whole word/exact match?
Option Explicit
Sub Dannottheman3()
Dim Cl As Range
Dim srch As Variant
For Each Cl In Range("A1", Range("A" & Rows.Count).End(xlUp))
For Each srch In Array("*quiz*", "*unit*", "*exam*", "*assessment*", "*test*") ' <= note the different use of the jolly (could be useful)
If LCase(Cl.Value) Like srch Then
Cl.Interior.Color = rgbLightBlue
Cl.Font.Bold = True
Exit For
End If
Next srch
Next Cl
End Sub