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
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,685
Messages
5,597,532
Members
414,152
Latest member
ReservoirDodds

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
Top