LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Can a function returning a date return an empty value?

Have the following function to change an integer number in the form of
yyyymmdd to a date.
The return value has to be declared as a date.

Function ConvertDates(ByVal intDate As Long) As Date

'to return a date seems to be the only way to
'guarantee that the day and month are not reversed
'the problem is that null values will be converted
'to 12:00:00 AM, this can be dealt with by either
'changing to "" after or
'do ActiveWindow.DisplayZeros = False
'------------------------------------------------------------

If intDate = 0 Or intDate = Null Then
Exit Function
Else
ConvertDates = Right(intDate, 2) & "/" & _
Mid(intDate, 5, 2) & "/" & _
Left(intDate, 4)
End If

End Function

The problem arises when the variable intDate is a NULL value or EMPTY.
In that case the value that eventually appears in the sheet will be 12:00:00
AM
Now is there any way to avoid this other than changing the value afterwards
to ""
or doing ActiveWindow.DisplayZeros = False?
Both these methods have their drawbacks and I would like to handle this in
the function.

Thanks for any advice.


RBS

 
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
Returning Data to an empty Cell Newfie809 Excel Worksheet Functions 1 August 22nd 08 09:19 PM
Can IF function return an empty cell? (not "") mtnw Excel Worksheet Functions 1 January 10th 07 11:01 PM
Date Function formula that will return the date of a specific week Greg Excel Worksheet Functions 4 June 12th 06 05:07 PM
Fix InputBox - Returning Empty String spurtniq[_3_] Excel Programming 7 December 31st 03 06:23 PM
VBA function returning the value EMPTY Helge V. Larsen[_2_] Excel Programming 1 November 24th 03 12:42 PM


All times are GMT +1. The time now is 04:16 PM.

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

About Us

"It's about Microsoft Excel"