View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Lost in Alabama Lost in Alabama is offline
external usenet poster
 
Posts: 26
Default Do Loop Won't Stop Looping

Thank you for your qick response. This code does not do anything to the data
at all. I think it may be bacause there are intermittent blank cells between
the top and bottom of the data in Column R. That is why I was trying to end
the loop by placing "END" in the cell below the last entry of data in Column
R.

Thanks

Lost


"Toppers" wrote:

Try:


With Columns("R:R")
Set c = .Find(What:="0", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Offset(0, -3).Resize(1, 3).ClearContents
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

"Lost in Alabama" wrote:

I am using the following code to find "0"in Column R, then select three cells
to the left and clear the contents in those cells. This code performs the
operation, however, it gets stuck in the loop...Can anyone help.

Thanks

Do Until ActiveCell.Value = "END"
Columns("R:R").Select
Selection.Find(What:="0", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(0, -3).Range("A1:D1").Select
Selection.ClearContents
Loop