LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
bst bst is offline
external usenet poster
 
Posts: 19
Default comparing times

i would like to flag certain cells based on the criteria below,
if the time in column A is between 5AM and 5PM and the word in column B is
False, i would like the cell in B marked red.
if the time in column A is between 5PM and 5AM and the word in column B is
True i would like the cell in B marked as red.

here is what i have so far:
If (sig = "TRUE" And shouldNotSigBool(time)) Then
.Cells(rowCtr, colSig).Interior.ColorIndex = 3 'after hours, no
sig needed
End If
If (sig = "FALSE" And shouldSigBool(time)) Then
.Cells(rowCtr, colSig).Interior.ColorIndex = 3 'normal hours,
sig needed
End If

and the functions:
Function shouldSigBool(time As Date) As Boolean
Const am As Date = #5:00:00 AM#
Const pm As Date = #5:00:00 PM#
If (time am And time < pm) Then
shouldSigBool = True
Else
shouldSigBool = False
End If
End Function

Function shouldNotSigBool(time As Date) As Boolean
Const am As Date = #5:00:00 AM#
Const pm As Date = #5:00:00 PM#
If (time < am And time pm) Then
shouldNotSigBool = True
Else
shouldNotSigBool = False
End If
End Function

from my sample data it looks as if the first conditional is completing,
however the second is not. can anyone spot a flaw in the logic? or is there
a beter way to do this?(i dont think an OR will work). unfortunatley i dont
know anyone else with any programming experience to bug with all my issues,
and it is terribly difficult to proofread my own work.

tia
bst
 
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
Comparing times.. [email protected] Excel Worksheet Functions 1 November 25th 07 03:16 AM
Comparing Times in Text Boxes to Times in Cells Matt[_39_] Excel Programming 1 August 6th 06 04:10 AM
Comparing two times changetires Excel Discussion (Misc queries) 2 July 26th 06 10:25 PM
Comparing Times Just Learning Excel Discussion (Misc queries) 4 August 19th 05 06:27 PM
Comparing Times trumpy81 New Users to Excel 2 June 29th 05 11:01 AM


All times are GMT +1. The time now is 05:26 AM.

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"