Returning by Function
Syed Zeeshan Haider wrote:
Can a function return two different data types
for two different conditions?
Yes.
Declare it As Variant
Function GiveMeA(What As String) As Variant
Select Case What
Case "Date": GiveMeA = Date()
Case "String": GiveMeA = "Hello"
End Select
End Function
=GIVEMEA("Date") ' with cell formatted as date
=GIVEMEA("String") ' cell format can still be date.
Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup
|