Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Loop macro help.

I have a MAcro that uses a the find ~Find function~. My
problem is when the macro can not find the word any
further it crashes instead of exiting the loop. I assume
(And we all know what that stands for)it is because of the
Microsoft error message of no matches were found. How can
I bypass this to exit the loop and continue on?

Any help is well recieved.
Pete W
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop macro help.

Test for the condition that causes the crash and put in defensive code that
handles the situation.

Beyond that, put up the appropriate code snippet and maybe someone can
sugges how to do the above.

--
Regards,
Tom Ogilvy

"Pete" wrote in message
...
I have a MAcro that uses a the find ~Find function~. My
problem is when the macro can not find the word any
further it crashes instead of exiting the loop. I assume
(And we all know what that stands for)it is because of the
Microsoft error message of no matches were found. How can
I bypass this to exit the loop and continue on?

Any help is well recieved.
Pete W



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Loop macro help.

The error states ~Run-Time Error 91 - Object Varible or
With Block Varible not set.~

Sub Find()
Page = "Page"

Do
Cells.Find(What:="Page", After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:= _
False).Activate
ActiveCell.Rows("1:11").EntireRow.Select
Selection.Delete Shift:=xlUp
ActiveCell.Offset(-6, 0).Range("A1").Select
Loop Until Page = ""
End Sub

Pete W
-----Original Message-----
Test for the condition that causes the crash and put in

defensive code that
handles the situation.

Beyond that, put up the appropriate code snippet and

maybe someone can
sugges how to do the above.

--
Regards,
Tom Ogilvy

"Pete" wrote in

message
...
I have a MAcro that uses a the find ~Find function~. My
problem is when the macro can not find the word any
further it crashes instead of exiting the loop. I assume
(And we all know what that stands for)it is because of

the
Microsoft error message of no matches were found. How

can
I bypass this to exit the loop and continue on?

Any help is well recieved.
Pete W



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with using a Macro Loop Mark Costello[_2_] Excel Discussion (Misc queries) 5 October 19th 07 02:01 PM
loop a macro jnjwilliams94 Excel Discussion (Misc queries) 4 August 26th 06 01:52 PM
how to put a loop in a macro? Khoshravan New Users to Excel 4 May 14th 06 01:22 PM
macro loop Helen Excel Discussion (Misc queries) 7 January 12th 05 02:42 PM


All times are GMT +1. The time now is 09:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"