excel - Apply 'On error GoTo' only for specific range -


i apply "on error goto err1" next few lines in code:

on error goto err1 activeworkbook.saveas filename:="c:\project\" & year(date) & "\" & _                    monthname(month(date)) & "\" & myfilename & ".xls" activeworkbook.close savechanges:=false 

that's it, after want disable error handling. tried add "on error resume" no results whatsoever. err1 handling looks this:

    err1:     msgbox ("project not overwrite file"), vbcritical     activeworkbook.close savechanges:=false 

this sub saves 1 sheet of file new .xls file, automatically saved date. in case there file generated, , person run macro clicks on "no" when asked overwrite file, err1 pop out message , prevent user getting debug message. however, error handling seems going through code not - after saving file sub generating auto email, , if person wants go project before clicking "send" button goes same err1 , closes original workbook (not separate sheet happens first time) , leaves user speechless. want avoid such situations users bad excel skills make these reports.

any suggestions?

this not answer cannot fit comment.

i assume did below. kinda sandwich suspected line producing error oeg , oeg0 below:

sub test()      on error goto err1     'access non existing named range     range("produceerror").select     'above produce error , handler kicks in     on error goto 0       msgbox "first error handled successfully"      'access invalid range address     range("b0").select     'above error out , err1 not called     'oeg<label> called once , not in entire macro      exit sub err1:     msgbox err.description     resume next  end sub 

now see, error handler not called again after oeg0 line.
normal error raised after second error producing line encountered.
now, might want check out review error handling.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -