Error calling range in Excel table causing crash -


complete vba newbie here.

i'm trying adapt code found on ron de bruin's site (bmail9.html specific tutorial/example). code straightforward enough , works in de bruin's file.

i able adapt work column name [days until liquidation due] within excel table [tbl_countdown] on secondary worksheet [interface2] of workbook. (this link file in question.1) however, when tried shift focus column name [days until liquidation due] in excel table [tbl_interface] in primary worksheet [interface], code has failed spectacularly: crashes excel (2013). (this link screenshot of error message on opening file.) , re-open it, error message generated. , more not (although not 100% of time), crashed excel regardless of whether choose 'end' or 'debug'.

 option explicit private sub worksheet_calculate()     dim formularange range     dim countdownrange range     dim notsentmsg string     dim mymsg string     dim sentmsg string     dim mylimit double     dim countdownfeedbackoffset double

notsentmsg = "not sent" sentmsg = "sent"  'below mylimit value run macro mylimit = 1  'set range formulas want check 

this line fails , crashes everything

set formularange = worksheets("interface").range("tbl_interface[liquidation in]") countdownfeedbackoffset = 3

on error goto endmacro: each formulacell in formularange.cells     formulacell         if isnumeric(.value) = false             .offset(0, 3).value = "not numeric"             mymsg = "not numeric"         else             if .value < mylimit                 mymsg = sentmsg                 if .offset(0, countdownfeedbackoffset).value = notsentmsg                     call mail_adv_liq_reminder                     'call mail_with_outlook1                 end if             else                 mymsg = notsentmsg             end if         end if         application.enableevents = false         .offset(0, 3).value = mymsg         application.enableevents = true     end next formulacell 

exitmacro: exit sub

endmacro: application.enableevents = true

msgbox "some error occurred." _ & vblf & err.number _ & vblf & err.description

end sub

to clear, 'ask' here figure out how call named range (rather hard-coding column name) code robust future additions or substractions of columns interface table. i'd know why it's failing enter image description herespectacularly it's crashing excel.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -