Sub ConditionalHighlightCells() 'Select a range of cells, then use the following code to highlight cells that contain a specified string Set rngMine = Selection For Each c In rngMine 'highlight the cell containing "error" If InStr(1, c.Value, "error", vbTextCompare) Then 'I use InStr here (contains), but you can use c.value="error" for an exact match With c.Interior .Color = 65535 'yellow 'Another format that can be used '.Color = RGB(200, 200, 255) ' RGB is Red, Green, Blue .Pattern = xlSolid End With End If Next c End Sub
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter