Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Max number of loops

Status
Not open for further replies.

StevePB

Technical User
Dec 6, 2001
92
GB
Excel 97 VBA - I have a macro that checks lines in a file for a specific character before loading the lines into a list box. When the list is more than 255 lines, the macro hangs (tested on two PCs - NT4 and Win98). I am using the follwing code to loop through the lines:

[tt]for i = 0 to listQuantity[/tt]

...do some stuff

[tt]next i[/tt]

I've tried using a do loop with the same result. Is there a maximum number of loops ? is there a work around ?
 
Hi StevenPB

The problem isn't with the macro or the loops its the listbox property. The max. number of lines in a listbox is 256 (0 - 255). Your macro is trying to write to something that doesn't exist.

Jon
 
Just out of curiosity is this a limitation of Office 97 ?
I have Office 2000 populating a listbox with 1000+ lines.
 
Thanks for your help Jon.

Any suggestions for an alternative? (upgrading to Office 2000 is not an option in this case).

Am I stuck with disabling scrolling, and using page up/page down buttons to rebuild the list? This is frustrating as the list only occasionally exceeds 255 lines.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top