Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop with a Find that will stop at the bottom of Doc

Status
Not open for further replies.

thomsons

Programmer
Dec 16, 2002
19
0
0
GB
Hi,

This is probably a really simple question but it driving me mad at the moment (I have done searches but I could just be putting in the wrong keywords).

Anyway, I have a loop which finds the cell that contains the text 'Gross Total:' then does some processing before looping to find the next reference to the word 'Gross Total:' etc.

The problem I am having is that when it gets to the last Find on the worksheet it then starts at the top again so the loop is never ending.

Is there a way I can stop the loop when it gets to the bottom of the Excel worksheet.

Thanks in advance for any assistance.

S.
 
From the Help for the FindNext Method:

When the search reaches the end of the specified search range, it wraps around to the beginning of the range. To stop a search when this wraparound occurs, save the address of the first found cell, and then test each successive found-cell address against this saved address.

A bit clumsy but that's what you have to do.

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top