Change colour of text if found in a column

Sdwd76

New Member
Joined
May 17, 2021
Messages
26
Office Version
  1. 365
Platform
  1. Windows
if a range of words are found (read, work, find) in col N
Then change the colour of these words to RED

is this possible please

vb button
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
  • If the words are in col N, will they be in a cell by themselves or might a cell contain "I read a book"?
  • Do you want the cell to turn red or just the text?
  • Where is the list of words to look for?
Could you give us 5 or 6 examples to show the variety of what might be in col N and explain exactly what you you want in relation to those examples?
 
Upvote 0
The cell will have various words or asset number so i would want to find the words mentioned above but also codes like DIM484884 Is an old name so if DIM* is found then also change cell red

Which ever is easier ideally if the word matches then change the cell colour?

Lets say we have a sheet called Words, in Col A we can have a list of words going down 10 rows
 
Upvote 0
Assuming the sheet with values in col N is the active sheet, see if this does what you want.

VBA Code:
Sub FindStrings()
  Dim RX As Object
  Dim rngN As Range, c As Range
  
  Set RX = CreateObject("VBScript.RegExp")
  RX.IgnoreCase = True
  RX.Pattern = Application.TextJoin("|", 1, Sheets("Words").Range("A2", Sheets("Words").Range("A" & Rows.Count).End(xlUp)))
  Set rngN = Range("N2", Range("N" & Rows.Count).End(xlUp))
  rngN.Interior.Color = xlNone
  For Each c In rngN
    If RX.Test(c.Value) Then c.Interior.Color = vbRed
  Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,851
Members
449,194
Latest member
HellScout

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