lkarthik25
New Member
- Joined
- Jul 6, 2014
- Messages
- 1
I have an excel where I have to check if an account is present in which of two account listings. Else, I have to go to the next account. The code I am using is:
When an account is not found in List1 I still get the error pop-up: Run-time '91' : Object variable or With block not set.
I am unable to see why the error handling is not doing its job. Please help me out.
Code:
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">[COLOR=#00008B]For[/COLOR] x=[COLOR=#800000]1[/COLOR] [COLOR=#00008B]to[/COLOR] acc_num
Sheets([COLOR=#800000]"List1"[/COLOR]).[COLOR=#00008B]Select
[/COLOR]Range([COLOR=#800000]"A1:A100"[/COLOR]).[COLOR=#00008B]Select
[/COLOR][COLOR=#00008B]On[/COLOR] [COLOR=#00008B]Error[/COLOR] [COLOR=#00008B]GoTo[/COLOR] CheckList2
Selection.Find(what:=x).Activate
[COLOR=#00008B]GoTo[/COLOR] Found
CheckList2:
Sheets([COLOR=#800000]"List2"[/COLOR]).[COLOR=#00008B]Select
[/COLOR]Range([COLOR=#800000]"A1:A100"[/COLOR]).[COLOR=#00008B]Select
[/COLOR][COLOR=#00008B]On[/COLOR] [COLOR=#00008B]Error[/COLOR] [COLOR=#00008B]GoTo[/COLOR] NotFound
Selection.Find(what:=x).Activate
Found:[COLOR=#808080]'More Code to execute if account is found
[/COLOR]NotFound:
[COLOR=#00008B]On[/COLOR] [COLOR=#00008B]Error[/COLOR] [COLOR=#00008B]GoTo[/COLOR] [COLOR=#800000]0
[/COLOR][COLOR=#00008B]Next[/COLOR] x
</code>
When an account is not found in List1 I still get the error pop-up: Run-time '91' : Object variable or With block not set.
I am unable to see why the error handling is not doing its job. Please help me out.
Last edited: