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: 20
Default One more loop question

Can someone please explain to me why the following code is skipping each row
in which the *first* instance of a new name appears in column A? In other
words, the Case Statement starts evaluating on the 2nd occurrence of the
name.

(thanks Bob, for all your help so far...)

TIA,

Patti


Option Explicit
Private Sub testloop()

Dim LstRow As Long
Dim i As Long
Dim AgtName As String
Dim oCurrent As Range
Dim FoundFlag As Boolean

LstRow = Range("a" & Rows.Count).End(xlUp).Row
AgtName = Range("A1").Value
Set oCurrent = Range("A1")
FoundFlag = False

For i = 1 To LstRow

If Cells(i, "A") = AgtName Then
Do While FoundFlag = False
Select Case Cells(i, 12)
Case ""
oCurrent.Offset(0, 15).Value = "I found a Null
cell"
FoundFlag = True
Case "This"
oCurrent.Offset(0, 15).Value = "I found This!"
FoundFlag = True
Case "That"
oCurrent.Offset(0, 15).Value = "I found That!"
FoundFlag = True
Case Else
FoundFlag = True
End Select
Loop
' message box added to confirm which row is being
evaluated
MsgBox "Currently evaluating row " & i & " for agent
" & AgtName
Else
AgtName = Cells(i, "A").Value
Set oCurrent = Cells(i, "A")
FoundFlag = False
End If
Next i

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
Loop question aelewis Excel Discussion (Misc queries) 2 October 24th 07 08:12 PM
Loop question N.F[_2_] Excel Discussion (Misc queries) 0 July 12th 07 08:02 PM
Password Loop question. Andy Tallent Excel Discussion (Misc queries) 1 April 8th 05 01:16 PM
another loop question Patti[_5_] Excel Programming 5 May 31st 04 07:43 AM
For loop question luvgreen[_3_] Excel Programming 1 February 20th 04 03:30 PM


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