Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Do loop error while using FindNext command

I am haveing stange bugs when I use the following code. If I step trough
line by line with the "F8" key the code will execute however if you just run
it normally it will bring up and error messge saying "Code execution has been
interupted"

If I click continue the code will break each time though the main loop but
give the correct results.

Below is a simplified version of my code. In my full program the i is not
what i'm matching there is actually an array variable that I index using i
[ex .find(what:=myArray(i))] but the problem loop is structured the same.

Any suggestions would be appreciated thanks.

Code:
Public Sub Sample()
Set c = Worksheets(1).Fange("A2")
For i = 1 To 100

Set c = Worksheets(1).Columns(1).Find(What:=i, After:=c,
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns,
SearchDirection:=xlNext)
If Not c Is Nothing Then
tempaddress = c.Address
tempRowStart = Range(tempaddress).Row
tempCount = 0
MsgBox tempRowStart
Do
Set c = Worksheets(1).Columns(1).FindNext(c)
tempCount = tempCount + 1
tempRowStop = tempRowStart + tempCount - 1
Loop While Not c Is Nothing And c.Address <
tempaddress
End If
Next

End Sub

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
Pivot Table Error Message - "Command Text not set for command obje Jeff Divian Excel Discussion (Misc queries) 0 November 7th 07 10:26 PM
loop and findnext John Excel Programming 4 August 25th 05 03:21 PM
Find, Findnext VBA Loop SMS - John Howard Excel Programming 5 November 13th 04 03:19 AM
Run-time Error '1004' Unable to get the findnext property... Tom Ogilvy Excel Programming 0 July 12th 04 04:27 PM
Loop command in Macro Rasoul Khoshravan Azar Excel Programming 1 January 8th 04 06:37 AM


All times are GMT +1. The time now is 10:42 PM.

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

About Us

"It's about Microsoft Excel"