Write the macro as a function and return the errorlevel from the function. As an example, this function will error if the string passed to it is empty:-
Code:
Option Explicit
Public Function MyFunction(ByVal sParameter As String) As Boolean
If Len(sParameter) = 0 Then
MyFunction = False
Else
MyFunction = True
End If
End Function
Then instead of merely calling the macro as a procedure, you call it as a function and test its value:-
Code:
If MyFunction(strValue) Then
[COLOR=black] MsgBox "Okay"[/COLOR]
Else
MsgBox "Error!"
End If
Obviously I've just put dummy comments in there but it gives you an idea of how to do it.
If you need to return a range of possible values from the function instead of just True/False, you'd do something like this:-
Code:
Option Explicit
Public Function MyFunction(ByVal Parameter As [I]{type}[/I]) As Integer
If [I]{some test fails}[/I] Then MyFunction = 1 : Exit Function
If [I]{some other test fails}[/I] Then MyFunction = 2 : Exit Function
If [I]{final test fails}[/I] Then MyFunction = 3 : Exit Function
[COLOR=green] ' passed all tests - flag as okay[/COLOR]
MyFunction = 0
End Function
then you'd test the value of the function as a number: 0 is okay, 1-3 indicate an error.