excel - vba issue with error handling -
all informations sheets explained here. i'll explain quickly:
i have 3 sheets (plan1, banco , db). plan1 has named ranges insert information , information stored on banco , copied bd (this last 1 saves past informations while banco has last information inserted).
i have code verify if named range alocacao exists on bd , if exists, they're load again on plan1. after this, can change name of alocacao after inserting new name in range named substituit_aloc using code below:
sub substituirproduto_click() dim foundcell range, firstaddr string, fnd string, newaloc range, long on error goto catch fnd = sheets("plan1").range("alocacao").value set newaloc = sheets("plan1").range("substituir_aloc") set foundcell = sheets("bd").columns(5).find(what:=fnd, _ after:=sheets("bd").cells(rows.count, 5), lookat:=xlpart, _ lookin:=xlformulas, searchorder:=xlbyrows, searchdirection:=xlnext) if not foundcell nothing firstaddr = foundcell.address end if until foundcell nothing = + 1 foundcell.value = newaloc.value set foundcell = sheets("bd").columns(5).findnext(after:=foundcell) if foundcell.address = firstaddr or >= 30 exit end if loop catch: msgbox "substituido!" end sub sometimes works , gets:
run-time error 91: object variable or block variable not set
and highlithed line:
if foundcell.address = firstaddr or >= 30 despite error, need without influencing end result. added on error goto catch doesn't show error message , finishs run code, i'm still getting error message.
someone know why still showing error message without being catched error handling?
if not foundcell nothing if foundcell.address = firstaddr or >= 30 exit end if end if
Comments
Post a Comment