Need help on loop

shekhar_pc

Board Regular
Joined
Jan 29, 2006
Messages
185
I am finding a word "Start" using the following code
Code:
Cells.Find(What:="Start", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False).Activate
Once the word is found, it does some works then again it find the next word "Start" and some more work.

I want to keep this in loop till the time the LAST word "Start" is found.

How to keep this in loop?
 
if u want to see if find is successful or not then

Inplace of Cells.Find(........).Activate use
Set test = Cells.Find(........)

If test Is Nothing then
..... not found
Else
Found
End If

But test will be Nothing only if first find itself is unsucessful ......
If u want to check if second find is sucessful or not then i do not see any other way than checking the address .... if same address is returned that means second find is unsuccessful .....

e.g. if B6 = Start and B8 = Start

So firstfind will be $B$6 .....
Cells.FindNext(After:=ActiveCell).Activate
Will activate cell B8 .....

If u have Start in only B6
then for every Cells.FindNext(After:=ActiveCell).Activate the cell activated will be B6 ....
Hope this helps .....
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,215,463
Messages
6,124,962
Members
449,200
Latest member
indiansth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top