Hi,
I just wanted to be sure that the value of a global variable in VBA is lost when an error is produced. There is not way to solve this problem?? Then , it is not good to use this kind of variables??
Thank you
Printable View
Hi,
I just wanted to be sure that the value of a global variable in VBA is lost when an error is produced. There is not way to solve this problem?? Then , it is not good to use this kind of variables??
Thank you
the variable may have nothing to do with the error,
the value of the global variables are retained, you should use proper error handling
if you comment out the on error goto, excel will break, but the variable will still retain valuevb Code:
On Error GoTo errh vtest = "whynot" 'public global variable Err.Raise 99 MsgBox "will not show" Exit Sub errh: vtest = vbNullString