Click to See Complete Forum and Search --> : reading excel row


leary
May 1st, 2001, 10:12 PM
when reading an excel row of unknown length how can i get the loop to stop when the cells are empty. I have limit set at 150 but list box shows empty after 119. I need to allow for larger sheets for expandibility but don't want to risk user selecting empty space in listbox. errors!
section of code below ...ole embedded

any suggestions appreciated


For intCol = 5 To 150 ' I want this to end of file
Debug.Print m_objSheet.Cells.Item(intRow, intCol)
lstDisplayDates.AddItem intCol & "." & " " & Trim(m_objSheet.Cells(intRow, intCol))

Next intCol

shree
May 1st, 2001, 10:16 PM
Use a Do...While Loop instead of the for loop.

leary
May 1st, 2001, 10:33 PM
did a little rework but works great. must have gotten into a thinking rut not to think of it myself.