excel - On error message -


i trying put on error message below code (so if there runtime error, want msgbox appear , code stop running when user clicks on error message. gave shot below having issue code doesn’t run to. wondering if me.

dim hl hyperlink        each hl in activesheet.hyperlinks  on error goto errormsgbox          hl.range.offset(0, 1).value = hl.address          hl.range.offset(0, 1).value = filedatetime(hl.range.offset(0, 1).value)         exit sub errormsgbox:            msgbox ("error")            resume next  next end sub   

your error handling needs go outside of loop. also, since want code stop running, should not use resume next statement. also, have exit sub inside for...next loop, maybe confused, means "loop" operate once, not desire.

revised:

dim hl hyperlink    each hl in activesheet.hyperlinks    on error goto errormsgbox        hl.range.offset(0, 1).value = hl.address        hl.range.offset(0, 1).value = filedatetime(hl.range.offset(0, 1).value)    next  '# put exit statement *before* error handler, , *outside* of loop    exit sub   '# error handler inform user , end sub. errormsgbox:    msgbox ("error")    err.clear end sub   

Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -