Macro to check for the existence of part of a word

kerlj001

New Member
Joined
Jun 2, 2011
Messages
10
I have a macro which highlights a row a particular colour based on matching a word in a column on that row.

'13 Urgency
Cells(intRow, cUrgency).Value = tmpUrgency
If tmpUrgency = "HIGH" Then
Rows(intRow & ":" & intRow).Interior.ColorIndex = 6
Rows(intRow & ":" & intRow).Interior.Pattern = xlSolid

End If
What I want to do is then check for the existence of part of a word 'xpedite' in a different column and make that red. This code doesnt work :-(

If tmpBrief = "*Expedite*" Then
Rows(intRow & ":" & intRow).Interior.ColorIndex = 3
Rows(intRow & ":" & intRow).Interior.Pattern = xlSolid

Any help appreciated
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi

Try:

Code:
If tmpBrief Like "*Expedite*" Then

Remark: the Like operator is, by default case sensitive. If you want it not case sensitive add at the beginning of the module "Option Compare Text" or use UCase() or LCase()
 
Upvote 0
As an aside:

Code:
Rows(intRow & ":" & intRow).Interior.ColorIndex = 3
can be replaced with

Code:
Rows(intRow).Interior.ColorIndex = 3
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,334
Members
452,907
Latest member
Roland Deschain

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