PDA

View Full Version : Solved: simple problem, please help



CZENHH
05-03-2011, 11:54 AM
I have a macro that pulls the S&P500 data.

A cell will have a value like this:
"Down 9.51 (.70%)"

or

"Up 4.51 (.36%)"

I want the font color to be red if down, green if up.


Sub changecolor()

If InStr(cells(18,10), "up") = "" Then
cells(18,10).Font.ColorIndex = 3
Else
cells(18,10).Font.ColorIndex = 4
End If

End sub


Thank you.

ntrauger
05-03-2011, 12:46 PM
I have replacedInStr(cells(18,10), "up") = ""
withInStr(1, Cells(18, 10), "up", vbTextCompare) = 0and it works on my machine.

CZENHH
05-03-2011, 01:03 PM
That works, thank you