T
Tony
I have a form that looks up a string value (CWWNo – Col “Aâ€) in a worksheet
(CWW List) and then places the string value into a form textbox (CWW1). I am
currently using the following code but I want the loop to end once I have
retrieved the first CWWNo date value (Col “Bâ€) that exceeds the LDate into
the form: What type of loop can I use that can loop the worksheet until it
meets this condition?
CWW List Worksheet
Col “A†Col “Bâ€
CWW1 03/16/2009
CWW1 04/6/2009
CWW1 4/27/2009
CWW1 5/18/2009
Set wsMaster = Workbooks("Collections Master Database2.xls").Worksheets("CWW
List")
CWWNo.Value = Combobox1.Column(23)
While Not IsEmpty(Worksheets("CWW List").Cells(LoopRow, LoopCol))
With wsMaster
If CWWNo = wsMaster.Range("a" & iRow + 0) Then
If LDate > wsMaster.Range("b" & iRow + 0) Then
iRow = iRow + 1
LoopRow = LoopRow + 1
Else
CWW1 = wsMaster.Range("b" & iRow + 0)
CWW2 = wsMaster.Range("b" & iRow + 0) + 21
CWW3 = wsMaster.Range("b" & iRow + 0) + 42
CWW4 = wsMaster.Range("b" & iRow + 0) + 63
CWW5 = wsMaster.Range("b" & iRow + 0) + 84
CWW6 = wsMaster.Range("b" & iRow + 0) + 105
CWW7 = wsMaster.Range("b" & iRow + 0) + 126
CWW8 = wsMaster.Range("b" & iRow + 0) + 147
CWW9 = wsMaster.Range("b" & iRow + 0) + 168
CWW10 = wsMaster.Range("b" & iRow + 0) + 189
'Exit Do
End If
Else
iRow = iRow + 1
LoopRow = LoopRow + 1
End If
End With
Wend
(CWW List) and then places the string value into a form textbox (CWW1). I am
currently using the following code but I want the loop to end once I have
retrieved the first CWWNo date value (Col “Bâ€) that exceeds the LDate into
the form: What type of loop can I use that can loop the worksheet until it
meets this condition?
CWW List Worksheet
Col “A†Col “Bâ€
CWW1 03/16/2009
CWW1 04/6/2009
CWW1 4/27/2009
CWW1 5/18/2009
Set wsMaster = Workbooks("Collections Master Database2.xls").Worksheets("CWW
List")
CWWNo.Value = Combobox1.Column(23)
While Not IsEmpty(Worksheets("CWW List").Cells(LoopRow, LoopCol))
With wsMaster
If CWWNo = wsMaster.Range("a" & iRow + 0) Then
If LDate > wsMaster.Range("b" & iRow + 0) Then
iRow = iRow + 1
LoopRow = LoopRow + 1
Else
CWW1 = wsMaster.Range("b" & iRow + 0)
CWW2 = wsMaster.Range("b" & iRow + 0) + 21
CWW3 = wsMaster.Range("b" & iRow + 0) + 42
CWW4 = wsMaster.Range("b" & iRow + 0) + 63
CWW5 = wsMaster.Range("b" & iRow + 0) + 84
CWW6 = wsMaster.Range("b" & iRow + 0) + 105
CWW7 = wsMaster.Range("b" & iRow + 0) + 126
CWW8 = wsMaster.Range("b" & iRow + 0) + 147
CWW9 = wsMaster.Range("b" & iRow + 0) + 168
CWW10 = wsMaster.Range("b" & iRow + 0) + 189
'Exit Do
End If
Else
iRow = iRow + 1
LoopRow = LoopRow + 1
End If
End With
Wend