Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Cell wont change colour

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
evil baby - 28 Feb 2006 18:37 GMT
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

Signature

evil baby

Tom Ogilvy - 28 Feb 2006 19:00 GMT
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

Signature

Regards,
Tom Ogilvy

> I'm pretty sure it has something to do with my end if but I'm not really
> used to excel programming.
[quoted text clipped - 26 lines]
> ActiveCell.Offset(0, 1).Select
> Loop
evil baby - 28 Feb 2006 19:21 GMT
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.

Signature

evil baby

Tom Ogilvy - 28 Feb 2006 21:32 GMT
Glad you were able to figure it out.

Signature

Regards,
Tom Ogilvy

> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.