LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Do Until Loop strange behavior

Hi,

I've written a Do Until loop that looks at whether a cell contains any info.
The Do until begins:

Do Until cells(X, 2) = ""

The problem is the loop when left to run stops half way through. However if
you step through it works fine.

Heres the loop code for info

Can anyone explain to me how to stop this behavior?

X = 6
Do Until Cells(X, 2) = ""
On Error GoTo ErrHand2
Sheets("SRS").Select
Set WTBFIND = Nothing
Set addrow = Nothing
WTBFIND = Cells(X, 4)
If WTBFIND < "" Then
addrow = "C"
If InStr(1, Cells(X, 2), "Yard") Then
addrow = Yard
Else
If InStr(1, Cells(X, 2), "Direct") Then
addrow = Direct
End If
End If
Sheets("wtb").Select
Cells.Find(what:=WTBFIND, After:=ActiveCell, LookIn:=xlValue,
LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
addcol = ActiveCell.Row
If addrow = "C" Then
Results = Cells(addcol, Yard) + Cells(addcol, Direct)
Else
Results = Cells(addcol, addrow)
End If
Else
Results = "0"
End If
ErrHan2: Sheets("SRS").Cells(X, 13) = Results
X = X + 1
Loop

Sheets("Srs").Select

Exit Sub

ErrHand2:
Results = "0"
Resume ErrHan2
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
Strange behavior Ritchie Excel Discussion (Misc queries) 2 September 26th 06 02:21 AM
INDIRECT - Strange behavior vezerid Excel Discussion (Misc queries) 5 April 19th 06 12:52 PM
Excel Mac OS X - Strange Behavior BrianP Excel Discussion (Misc queries) 0 January 1st 06 08:07 AM
Strange behavior DeRussie Setting up and Configuration of Excel 4 November 26th 05 05:41 PM
Strange behavior. Wiley Coyote Excel Discussion (Misc queries) 7 October 18th 05 04:35 PM


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