LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Conditional formatting - why doesn't this work?

Please help, I'm stumped.

I've set up a worksheet calculate macro to colour certain rows based on the
contents of the adjacent cells, but one of the specifications isn't working
and I've tried everything.

This spec works:
'Highlight if later than 90 days since request
ElseIf myCE.Value < Now - 90 And myCE.Offset(0, 1).Value = "" _
And myCE.Offset(0, -4).Value = "No" And myCE.Offset(0, 4).Value _
= "Requester/PM" And myCE.Offset(0, -8).Value < "Cancelled" Then
Range(myCE, myCE.Offset(0, -17)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, 4)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, -17)).Interior.ColorIndex = 22 'light red
Range(myCE, myCE.Offset(0, 4)).Interior.ColorIndex = 22

But this one doesn't:

ElseIf myCE.Value = "" And myCE.Offset(0, 1).Value < (Now - 60) And _
myCE.Offset(0, -4).Value = "No" And myCE.Offset(0, 4).Value = And _
"Requester/PM" And myCE.Offset(0, -8).Value < "Cancelled" Then
Range(myCE, myCE.Offset(0, -17)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, 4)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, -17)).Interior.ColorIndex = 36 'light yellow
Range(myCE, myCE.Offset(0, 4)).Interior.ColorIndex = 36

Here is the full code:

Private Sub Worksheet_Calculate()
Dim myCE As Range
Dim WatchRange1 As Range

'Application.ScreenUpdating = False

Set WatchRange1 = Range("BQDate")

For Each myCE In WatchRange1

If myCE.Value = "" And _
myCE.Offset(0, -4).Value = "No" Then
Range(myCE, myCE.Offset(0, -17)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, 4)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, -17)).Interior.ColorIndex = 0
Range(myCE, myCE.Offset(0, 4)).Interior.ColorIndex = 0
'Highlight Power Company if later than 90 days since request
ElseIf myCE.Value = "" And _
myCE.Offset(0, -4).Value = "Yes" Then
Range(myCE, myCE.Offset(0, -17)).Font.ColorIndex = 16
Range(myCE, myCE.Offset(0, 4)).Font.ColorIndex = 16
Range(myCE, myCE.Offset(0, -17)).Interior.ColorIndex = 15
Range(myCE, myCE.Offset(0, 4)).Interior.ColorIndex = 15
ElseIf myCE.Value = "" And myCE.Offset(0, 1).Value < (Now - 60) And _
myCE.Offset(0, -4).Value = "No" And myCE.Offset(0, 4).Value =
"Requester/PM" And _
myCE.Offset(0, -8).Value < "Cancelled" Then
Range(myCE, myCE.Offset(0, -17)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, 4)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, -17)).Interior.ColorIndex = 36 'light yellow
Range(myCE, myCE.Offset(0, 4)).Interior.ColorIndex = 36
ElseIf myCE.Value = "" And myCE.Offset(0, 1).Value < (Now - 60) And _
myCE.Offset(0, -4).Value = "No" And myCE.Offset(0, 4).Value = "Power
Company" And _
myCE.Offset(0, -8).Value < "Cancelled" Then
Range(myCE, myCE.Offset(0, -17)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, 4)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, -17)).Interior.ColorIndex = 36 'light yellow
Range(myCE, myCE.Offset(0, 4)).Interior.ColorIndex = 36
ElseIf myCE.Value < Now - 90 And myCE.Offset(0, 1).Value = "" _
And myCE.Offset(0, -4).Value = "No" And myCE.Offset(0, 4).Value = "Power
Company" _
And myCE.Offset(0, -8).Value < "Cancelled" Then
Range(myCE, myCE.Offset(0, -17)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, 4)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, -17)).Interior.ColorIndex = 22 'light red
Range(myCE, myCE.Offset(0, 4)).Interior.ColorIndex = 22
'Highlight Requester/PM if later than 90 days since request
ElseIf myCE.Value < Now - 90 And myCE.Offset(0, 1).Value = "" _
And myCE.Offset(0, -4).Value = "No" And myCE.Offset(0, 4).Value =
"Requester/PM" _
And myCE.Offset(0, -8).Value < "Cancelled" Then
Range(myCE, myCE.Offset(0, -17)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, 4)).Font.ColorIndex = 0 '
Range(myCE, myCE.Offset(0, -17)).Interior.ColorIndex = 22 'light red
Range(myCE, myCE.Offset(0, 4)).Interior.ColorIndex = 22

Else
Range(myCE, myCE.Offset(0, -17)).Font.ColorIndex = 0 'black
Range(myCE, myCE.Offset(0, 4)).Font.ColorIndex = 0 'black
Range(myCE, myCE.Offset(0, -17)).Interior.ColorIndex = 0 'blank
Range(myCE, myCE.Offset(0, 4)).Interior.ColorIndex = 0 'blank
'0 Blank/Black
'3 Red
'36 Yellow
'15 Grey
'34 Light blue
'16 Dark grey
'
End If

Next myCE

'Application.ScreenUpdating = True

End Sub

Kind regards
Dylan


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting - Not all colors work? PSS New Users to Excel 1 April 18th 08 11:49 PM
Will Conditional Formatting work? Lisa Excel Worksheet Functions 6 September 7th 07 03:04 PM
Will Conditional Formatting work? jennjenn Excel Worksheet Functions 2 August 1st 07 05:40 PM
Conditional Formatting work automatically Tiya Excel Programming 3 March 17th 05 12:35 PM
Conditional Formatting Work around? John Excel Worksheet Functions 2 October 29th 04 08:10 AM


All times are GMT +1. The time now is 05:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"