ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   error trapping (https://www.excelbanter.com/excel-programming/321276-error-trapping.html)

[email protected]

error trapping
 
Hi all,

I have just used error trapping for the first time and i am having some
problems with it. here it is

sub test()

on error goto errortrap
Unload Me


Sheets("codes").Select

UserForm1.Show

errortrap:

unload me
userform7.show


if there an error i wish to display another userform, however at the
moment if theres no error the program will run but still display the
userform7 at the end of the program instead of ignoring it, any help
greatly accepted

regards

johny


anonymousA

error trapping
 
a écrit :
Hi all,

I have just used error trapping for the first time and i am having some
problems with it. here it is

sub test()

on error goto errortrap
Unload Me


Sheets("codes").Select

UserForm1.Show

errortrap:

unload me
userform7.show


if there an error i wish to display another userform, however at the
moment if theres no error the program will run but still display the
userform7 at the end of the program instead of ignoring it, any help
greatly accepted

regards

johny

Hi,

before errortrap:, insert a line with the instruction Exit Sub and it'll
fix it.

So long

Lonnie M.

error trapping
 
Hi, think you want to exit the sub before userform7.show is executed.
Then if there is an error, I believe that it will go to your
errortrap:, which will then show userform7.

sub test()
on error goto errortrap
Unload Me

Sheets("codes").Select

UserForm1.Show

exit sub
errortrap:

unload me
userform7.show

exit sub

Good luck--Lonnie



All times are GMT +1. The time now is 07:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com