-
Is it possible to write vba code to create a conditional format on cells?
Hi, everyone! I will like to know how to write vba code to firstly, identify various cells for example that have 42, and color those cells with the color red. I would like to be able to use a macro or vba code to this. Can this be done? If so, how can this be done? Do you have any samples?
Thanks for your contributions
-
Is there a reason you wouldn't just use CV?
-
I would use CV, but for a simple macro try
[vba]Sub Macro1()
Application.ReplaceFormat.Interior.ColorIndex = 3
Cells.Replace What:="42", Replacement:="42", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=True
End Sub
[/vba]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules