Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Using IsError

I have two list boxes for users to select dates, and want to use IsError to
generate a msgbox if the user tries to run the code without selecting a date.
The current code is:

If CDate(lstTo) < CDate(lstFrom) Then
MsgBox "The 'To' date should not be before the 'From' date!"
End If

This covers the user entering the dates backwards, but how do I make this
work if the user omits the dates completely?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Using IsError

Hi,

One way

If Not IsDate(lstTo) Or Not IsDate(lstFrom) Then
MsgBox "You must enter 2 dates!"
ElseIf CDate(lstTo) < CDate(lstFrom) Then
MsgBox "The 'To' date should not be before the 'From' date!"
End If

Mike

"Merlynsdad" wrote:

I have two list boxes for users to select dates, and want to use IsError to
generate a msgbox if the user tries to run the code without selecting a date.
The current code is:

If CDate(lstTo) < CDate(lstFrom) Then
MsgBox "The 'To' date should not be before the 'From' date!"
End If

This covers the user entering the dates backwards, but how do I make this
work if the user omits the dates completely?


Reply
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
IsError help Jim Excel Discussion (Misc queries) 2 September 4th 09 02:03 PM
IF ISERROR John Moore Excel Discussion (Misc queries) 5 June 26th 06 02:01 PM
ISERROR Dee Excel Worksheet Functions 4 August 24th 05 07:37 PM
iserror Walshy Excel Discussion (Misc queries) 3 December 19th 04 05:13 PM
ISERROR Steve P[_4_] Excel Programming 0 June 23rd 04 07:19 AM


All times are GMT +1. The time now is 09:01 PM.

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

About Us

"It's about Microsoft Excel"