error handling - Using the find method in excel -
i struggling figure out how figure out if search string not found in excel, tried
isnothing(rfoundcell)
but not work, says method can not found
and iserror not work
rcount = settings.rowheadertempfile + 1 lrow2 set rfoundcell = range("a" & settings.rowheader + 1) set rfoundcell = ws.columns(1).find(what:=ws2.cells(rcount, partnumberws2).value, after:=rfoundcell, lookin:=xlvalues, lookat:=xlpart, searchorder:=xlbyrows, searchdirection:=xlnext, matchcase:=false) if iserror(rfoundcell.row) ' fails here lrow = lrow + 1
since rfoundcell
nothing
doesn't have .row
property.
if rfoundcell nothing
seems more convenient handling, in real life situations wouldn't use handling, dependent procedure should based on if not rfoundcell nothing then
criterium.
for rcount = settings.rowheadertempfile + 1 lrow2 set rfoundcell = range("a" & settings.rowheader + 1) set rfoundcell = ws.columns(1).find(what:=ws2.cells(rcount, partnumberws2).value, after:=rfoundcell, lookin:=xlvalues, lookat:=xlpart, searchorder:=xlbyrows, searchdirection:=xlnext, matchcase:=false) if not rfoundcell nothing 'do stuff else lrow = lrow + 1 end if
Comments
Post a Comment