![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 15
|
Is there a way to use a formula like :
If (Cells(i,5).Value > "12:00 AM") And (Cells(i,5).Value < "6:00 AM") Then... to determine if a given cell occurs between the two listed times? Thanks! |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
|
Quote:
for a cell formatted as time. if it is time and date it would be if(MOD(A1,1)<.25,... |
|
|
|
|
|
|
#3 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Quote:
I don't know the context in which you are using this formula, but syntax-wise the following will work =IF(AND(I5>"12:00 AM"+0,I5<"6:00 AM"+0),"YES","NO") _________________ Yogi Anand Edit: Deleted inactive website from hardcoded signature [ This Message was edited by: Yogi Anand on 2003-01-19 14:07 ] |
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Calgary, Alberta Canada
Posts: 2,065
|
What do you mean by 12:00 AM? If you want to test if time is between 0:00 and 6:00. Put the criteria in say B1 and B2 and use =AND(I5>B1,I5 |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Hi Dave:
Logic wise, I agree with you. However in the original post, StrangeLuck had asked if he could directly use 12:00 AM and 6:00 AM in an IF formula, that is why response to him that I don't know in what context he asked the question, but syntax-wise 12:00 AM and 6:00 AM could be directly used in the formula. Regards! Yogi Anand |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Calgary, Alberta Canada
Posts: 2,065
|
If (Cells(i,5).Value > "12:00 AM") And (Cells(i,5).Value < "6:00 AM") Then... How can a value be both greater than 12:00 and less than =6:00? |
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Quote:
="12:00 AM"+0 is coerced into 0.00 and ="6:00 AM"+0 is coerced into 0.25 Regards! Yogi Anand |
|
|
|
|
|
|
#8 |
|
New Member
Join Date: Mar 2002
Posts: 15
|
Sorry, I should have been clearer in my question, I suppose. I am looking for a VBA method whereby I could determine if a value in a certain cell, say B1, is between 12:00 AM and 6:00 AM. Thanks!
|
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Feb 2002
Location: Calgary, Alberta Canada
Posts: 2,065
|
Do not use 12:00 AM consider with cell references =AND(I5>B1,I5 =AND(I5>"6:00"+0,I5<"12:00"+0) or =AND(I5>0.25,I5<0.5) |
|
|
|
|
|
#10 | |
|
New Member
Join Date: Mar 2002
Posts: 15
|
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|