ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to "bypass" run-time error '91'???? (https://www.excelbanter.com/excel-programming/318880-how-bypass-run-time-error-91-a.html)

Jeff[_43_]

How to "bypass" run-time error '91'????
 
The following is part of a macro that will generate the following error
message:

"Run-time error '91':
Object variable or With block variable not set

I run this macro on an imported XML datatable that may or may not have
a particular dataset (see macro below). Since it's okay if this
dataset is missing (i.e., some projects may or may not have this
information - if not, then this dataset will be missing entirely), what
can be done to "bypass" this error statement?

Cells.Find(What:="/PROJECT/ISSUES/ISSUE/FOLLOWUP/ACTUAL_DATE", After:=
_ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
_SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False).Activate


Tom Ogilvy

How to "bypass" run-time error '91'????
 
dim rng as Range

set rng = Cells.Find(What:="/PROJECT/ISSUES/ISSUE/FOLLOWUP/ACTUAL_DATE",
After:=
_ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
_SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False)

if not rng is nothing then
rng.Activate
else
msgbox "Missing dataset"
End if

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
oups.com...
The following is part of a macro that will generate the following error
message:

"Run-time error '91':
Object variable or With block variable not set

I run this macro on an imported XML datatable that may or may not have
a particular dataset (see macro below). Since it's okay if this
dataset is missing (i.e., some projects may or may not have this
information - if not, then this dataset will be missing entirely), what
can be done to "bypass" this error statement?

Cells.Find(What:="/PROJECT/ISSUES/ISSUE/FOLLOWUP/ACTUAL_DATE", After:=
_ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
_SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False).Activate





All times are GMT +1. The time now is 10:05 AM.

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