Consulting

Results 1 to 3 of 3

Thread: Solved: simple problem, please help

  1. #1
    VBAX Newbie
    Joined
    Apr 2011
    Posts
    4
    Location

    Thumbs up Solved: simple problem, please help

    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.


    [VBA]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[/VBA]


    Thank you.

  2. #2
    VBAX Regular ntrauger's Avatar
    Joined
    May 2011
    Location
    Monticello
    Posts
    38
    Location
    I have replaced[vba]InStr(cells(18,10), "up") = ""[/vba]
    with[vba]InStr(1, Cells(18, 10), "up", vbTextCompare) = 0[/vba]and it works on my machine.

  3. #3
    VBAX Newbie
    Joined
    Apr 2011
    Posts
    4
    Location
    That works, thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •