if time > time then ...

nicolewh

Well-known Member
Joined
Aug 7, 2009
Messages
554
I have this macro:
Code:
If DateValue(SundayBegin.Value) >= DateValue(SundayEnd.Value) _
And Not SundayBegin.Value = "" _
And Not SundayEnd.Value = "" And Not SundayEnd.Value = "Continued" Then
MsgBox "The time in the Sunday Begin box must be before the Sunday End Box.", vbExclamation, "Add"
Me.txtCompName.SetFocus
Exit Sub
End If
- note: sundayend, and sundaybegin are comboboxes.
When I place 6 AM in sundaybegin combobox and 10 AM in the sundayend box I receive that message. It doesn't make any sense. Very frustrating.

Any insight would be very helpful.

Thanks! :)
Nicole
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Nicole

I don't think 6 AM and 10 AM are being recognised correctly.

Try TimeValue instead of DateValue.
Code:
  If TimeValue(SundayBegin.Value) >= TimeValue(SundayEnd.Value) _
       And Not SundayBegin.Value = "" _
       And Not SundayEnd.Value = "" And Not SundayEnd.Value = "Continued" Then
        MsgBox "The time in the Sunday Begin box must be before the Sunday End Box.", vbExclamation, "Add"
        Exit Sub
    End If
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,423
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top