ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macros & vba (https://www.excelbanter.com/excel-programming/321453-macros-vba.html)

spak1971

Macros & vba
 
I'm using excel 2000.
How can I search a range of cells and get only those cells to change color
if they meet certain criteria eg: "a text string"? So far I've only been able
to get the entire range to change!!

Rob van Gelder[_4_]

Macros & vba
 
Here are two ways:

By Conditional Formatting

Highlight column A
From the Format menu, Conditional Formatting
Formula Is: =A1="a text string"

or by Macro

Sub test()
Dim rng As Range

With ActiveSheet
For Each rng In Range(.Cells(1, 1), .Cells(Rows.Count, 1).End(xlUp))
If rng.Value = "a text string" Then rng.Interior.Color =
RGB(255, 0, 0)
Next
End With
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"spak1971" wrote in message
...
I'm using excel 2000.
How can I search a range of cells and get only those cells to change color
if they meet certain criteria eg: "a text string"? So far I've only been
able
to get the entire range to change!!





All times are GMT +1. The time now is 12:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com