+ Reply to Thread
Results 1 to 4 of 4

Cell wont change colour

  1. #1
    Registered User
    Join Date
    02-27-2006
    Posts
    16

    Cell wont change colour

    I'm pretty sure it has something to do with my end if but I'm not really used to excel programming.

    Range("G24").Select
    Do While ActiveCell <> 0
    x = ActiveCell.Offset(-1, 0).Value
    If ActiveCell.Value >= (x - (x * 0.06)) Then
    If ActiveCell.Value <= (x + (x * 0.06)) Then
    ActiveCell.Interior.ColorIndex = 35
    ActiveCell.Font.ColorIndex = 1
    End If
    'HERE IS WHERE THE PROBLEM IS - it wont recognize the next elseif statment. I just skips it. Everything else works fine, just not this statement

    '***********************************************
    ElseIf ActiveCell.Value > (x + (x * 0.06)) Then
    ActiveCell.Interior.ColorIndex = 3
    ActiveCell.Font.ColorIndex = 2

    '***********************************************
    ElseIf ActiveCell.Value < (x - (x * 0.11)) Then
    ActiveCell.Interior.ColorIndex = 3
    ActiveCell.Font.ColorIndex = 2
    Else
    ActiveCell.Interior.ColorIndex = 36
    ActiveCell.Font.ColorIndex = 1
    End If
    ActiveCell.Offset(0, 1).Select
    Loop

  2. #2
    Tom Ogilvy
    Guest

    Re: Cell wont change colour

    Range("G24").Select
    Do While ActiveCell <> 0
    x = ActiveCell.Offset(-1, 0).Value
    If ActiveCell.Value >= (x - (x * 0.06)) or _
    ActiveCell.Value <= (x + (x * 0.06)) Then
    ActiveCell.Interior.ColorIndex = 35
    ActiveCell.Font.ColorIndex = 1
    ElseIf ActiveCell.Value > (x + (x * 0.06)) Then
    ActiveCell.Interior.ColorIndex = 3
    ActiveCell.Font.ColorIndex = 2
    ElseIf ActiveCell.Value < (x - (x * 0.11)) Then
    ActiveCell.Interior.ColorIndex = 3
    ActiveCell.Font.ColorIndex = 2
    Else
    ActiveCell.Interior.ColorIndex = 36
    ActiveCell.Font.ColorIndex = 1
    End If
    ActiveCell.Offset(0, 1).Select
    Loop


    --
    Regards,
    Tom Ogilvy

    "evil baby" <[email protected]> wrote
    in message news:[email protected]...
    >
    > I'm pretty sure it has something to do with my end if but I'm not really
    > used to excel programming.
    >
    > Range("G24").Select
    > Do While ActiveCell <> 0
    > x = ActiveCell.Offset(-1, 0).Value
    > If ActiveCell.Value >= (x - (x * 0.06)) Then
    > If ActiveCell.Value <= (x + (x * 0.06)) Then
    > ActiveCell.Interior.ColorIndex = 35
    > ActiveCell.Font.ColorIndex = 1
    > End If
    > 'HERE IS WHERE THE PROBLEM IS - it wont recognize the next elseif
    > statment. I just skips it. Everything else works fine, just not this
    > statement
    >
    > '***********************************************
    > ElseIf ActiveCell.Value > (x + (x * 0.06)) Then
    > ActiveCell.Interior.ColorIndex = 3
    > ActiveCell.Font.ColorIndex = 2
    >
    > '***********************************************
    > ElseIf ActiveCell.Value < (x - (x * 0.11)) Then
    > ActiveCell.Interior.ColorIndex = 3
    > ActiveCell.Font.ColorIndex = 2
    > Else
    > ActiveCell.Interior.ColorIndex = 36
    > ActiveCell.Font.ColorIndex = 1
    > End If
    > ActiveCell.Offset(0, 1).Select
    > Loop
    >
    >
    > --
    > evil baby
    > ------------------------------------------------------------------------
    > evil baby's Profile:

    http://www.excelforum.com/member.php...o&userid=31983
    > View this thread: http://www.excelforum.com/showthread...hreadid=517430
    >




  3. #3
    Registered User
    Join Date
    02-27-2006
    Posts
    16
    Thanks again for the help, wasn't sure how logical and/or worked in VBA.

    I had to change your 'Or' to an 'And' but it worked like a charm after that.

  4. #4
    Tom Ogilvy
    Guest

    Re: Cell wont change colour

    Glad you were able to figure it out.

    --
    Regards,
    Tom Ogilvy

    "evil baby" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Thanks again for the help, wasn't sure how logical and/or worked in
    > VBA.
    >
    > I had to change your 'Or' to an 'And' but it worked like a charm after
    > that.
    >
    >
    > --
    > evil baby
    > ------------------------------------------------------------------------
    > evil baby's Profile:

    http://www.excelforum.com/member.php...o&userid=31983
    > View this thread: http://www.excelforum.com/showthread...hreadid=517430
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1