LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Loop Does Not Stop

change this
Do Until IsEmpty(ActiveCell)

to just
DO

"Patrick Molloy" wrote:

first, dim c as Range

the FIND function is circular, ie once its found the last item, it starts
again. Look up FIND in HELP and in the example they save the address of the
first find and loop until it gets back there again

Public Sub RowFix()

Dim c As Range
DIM addr as String
Dim FirstRow As Integer

With Worksheets(1).Range("A6:A4000")
Set c = .Find("01152", LookIn:=xlValues)
If Not c Is Nothing Then
FirstRow = c.Row + 1
Addr = C.Address
Do Until IsEmpty(ActiveCell)
c.EntireRow.Insert
c.Offset(-1, 0).Value = "Next"
Set c = .FindNext(c)
Loop Until c.Address = Addr
End If
End With

End Sub

(i haven't tested this)



"pwk" wrote:

Why won't this stop looping? Where did I go wrong. It works fine but
it goes on and on.
thanks in Advance

Public Sub RowFix()

Dim c As Variant
Dim FirstRow As Integer

With Worksheets(1).Range("A6:A4000")
Set c = .Find("01152", LookIn:=xlValues)
If Not c Is Nothing Then
FirstRow = c.Row + 1
Do Until IsEmpty(ActiveCell)
c.EntireRow.Insert
c.Offset(-1, 0).Value = "Next"
Set c = .FindNext(c)
Loop
End If
End With

End Sub

 
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
Stop Loop pjd33 Excel Programming 4 May 24th 07 05:21 PM
Do Loop doesn't stop [email protected][_2_] Excel Programming 5 May 22nd 07 07:32 PM
Hot key to stop a LOOP joopdog[_3_] Excel Programming 5 February 9th 06 06:51 PM
how to stop a loop L775 Excel Programming 6 November 29th 04 08:37 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 02:01 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"