Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Pivot Table Error Message - "Command Text not set for command obje | Excel Discussion (Misc queries) | |||
loop and findnext | Excel Programming | |||
Find, Findnext VBA Loop | Excel Programming | |||
Run-time Error '1004' Unable to get the findnext property... | Excel Programming | |||
Loop command in Macro | Excel Programming |