View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
shikarishambu shikarishambu is offline
external usenet poster
 
Posts: 5
Default Excel VBA - checking a date field for null

Hi,
I have a VBA function in excel that checks a date field to see if it is
null/ in past or in future.

The problem is even if the filed is blank the function returns info stating
it is in the past

Here is the function

Function CheckDate(dtTest as Date)

If Len(Trim(dtTest)) = 0 Then 'Tried IsNull - did not work
CheckDate = "BLANK"
ElseIf dtTest < Date Then
CheckDate = "PAST"
Else
CheckDate = "Future"
End If

Is there a way to check if the date field is "empty'

TIA