Question : Loop through rows in listbox

Hi,

I am trying to color text in a listbox based on a condition.  On the listbox's OnUdate event I have something like:

If Me.mylistbox = "1234" Then
mylistbox.forecolor = vbRed
End If

But obviously this won't run because there could be more than one row.  I can't quite remember the syntax (plus I have run out of time) to loop through all rows.  It's probably something like:

for (all rows, while rows exist)
If Me.mylistbox = "1234" Then
mylistbox.forecolor = vbRed
End If
end for


Any suggestions?

Answer : Loop through rows in listbox

"The lines need to be different colors based on certain conditions."

Well, no can do in A2007, so ... again, unless the A2007 list box has changed, then no can do. How about using a continuous form to emulate a list box, and then apply Conditional Formatting to the rows to get your colors.

mx
Random Solutions  
 
programming4us programming4us