Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text colour / cell colour

Status
Not open for further replies.

jillseurre

Technical User
Aug 28, 2003
37
0
0
GB
how can i write a function that will also change the cell or font colour.

ie

if(x>1, "greencolour","redcolour") and also return the result
x=4 result = 4 in green
x=0 result = 0 in red
 
ON a selected cell the following code will change the colour

Selection.Font.ColorIndex = 3 'Changes font colour
With Selection.Interior
.ColorIndex = 6 'Changes cell colour
.Pattern = xlSolid
End With

hope that helps

dyarwood
 
No need for code - just use conditional formatting

Select cells
Format>Conditional formatting
Select Value Is = 4
choose green font
2nd condition
Value Is = 0
choose red font

et voila


Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top