Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    May 2004
    Toronto, Ontario, Canada
    Thanked 0 Times in 0 Posts

    memory management (Excel 2000)

    Hi all,

    I have a combobox that I made I used a For Next Loop- got a problem
    Sub ()
    Dim I as long
    For I = 0 to 100000000
    Userform1.combox1.additem I
    Next I
    End sub

    Here's my question, It takes forever to run this procedure, Is there a way to add an item to your list without using a For Next Loop? I know all the values in the list, is there a way of using a redim Preserve counter, so that the list is always there? Then erase the list?

    Thanks, Darryl.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: memory management (Excel 2000)

    A combo box with that many items in the list is bizarre. I can't think of a good reason why you would want to present 100,000,000 items.

    A much faster way to populate the list is as follows, but it still won't let you add 100,000,000 items:

    Sub FillCombo()
    Const n As Long = 10000
    Dim i As Long
    Dim a(1 To n) As Long
    For i = 1 To n
    a(i) = i
    Next i
    Me.ComboBox1.List = a
    Erase a
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts