• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

function: how to return error flag

coke2011

New Member
hi all)

how to return error frag

in case when function can't execute properly

expecting that this function will return Range object


Code:
Function getRange(startCell As String) As Range

dim everythingIsOk as boolean

...

if everythingIsOk then

Set getRange= Range(....

else

Set getRange = ????????

end if

End Function


thanx!
 
If you dim the function as a range, you won't be able to have it return anything other than a range. You could do this by using a global defined boolean however...

[pre]
Code:
Dim EverythingIsOK as Boolean
Function getRange(startCell As String) As Range
...
End Function
[/pre]
Then your next piece of code, wherever you're calling the function from, can check the status of EverythingIsOK.
 
Back
Top