VBA - Excel - On Error goto userform -



VBA - Excel - On Error goto userform -

when there error, want go userform , alter info entered on form , re pass macro , go on from: if len(dir(sfilepath & newfol, vbdirectory)) = 0...

if len(dir(sfilepath & newfol, vbdirectory)) = 0 mkdir sfilepath & newfol & "\" on error goto userform1 else msgbox ("folder exists please re come in new folder name") 'end userform1.show moveandsave_reports end if

the above give me error message: compile error: label not defined @ "on error goto userform1"

when utilize "on error goto" statement, you're telling programme when hits error, skip specific line in current procedure. example:

on error goto errorhandler x = 10 / 0 msgbox "x = infinity!" errorhandler: msgbox "cannot split zero"

in example, when code hits error (after "on error" statement), stop it's doing , begin executing code @ errorhandler label (it's label because of colon @ end). running code, never see message box saying x = infinity. 1 time hits error trying split zero, jump downwards errorhandler label , give me message saying can't split zero.

chip pearson has introduction basic error handling here.

vba error-handling excel-vba

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -