Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This worked for me
Function checkdate(dttest As Variant) If dttest = "" Then 'returns no value when the dttest is blank Else If DateSerial(Year(dttest), Month(dttest), Day(dttest)) _ DateSerial(Year(Now), Month(Now), Day(Now)) Then checkdate = "Future" Else checkdate = "Past" End If End If End Function shikarishambu wrote: 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What is "dtTest"?
If it is a named cell, then try referencing it: Range("dtTest") example - If Len(Trim(Range("dtTest"))) = 0 Then Regards, Paul "shikarishambu" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I want to use a different cell if my date field is NULL/BLANK | Excel Worksheet Functions | |||
How to Join/concatenate a date field with a time field in Excel? | Excel Discussion (Misc queries) | |||
Checking that any cells are null | Excel Worksheet Functions | |||
Handling Null Field in Macro Loop | Excel Programming | |||
Null Field Result in Loop | Excel Programming |