+ Reply to Thread
Results 1 to 3 of 3

Adding Items to an array

  1. #1
    Registered User
    Join Date
    07-01-2005
    Posts
    7

    Adding Items to an array

    Having a bit of trouble with the following code. I am attempting to create a drop down box that contains the contents of a list of cells. The cells aren't in a fixed location and there could be a different number of items depending on another list box. So the array can't be a fixed size. How can I add the items I want to the array and then display them in the combobox?

    Thanks

    Please Login or Register  to view this content.
    Last edited by musictech; 07-25-2005 at 01:41 PM.

  2. #2
    Registered User
    Join Date
    07-01-2005
    Posts
    7
    Any ideas?

  3. #3
    Tom Ogilvy
    Guest

    Re: Adding Items to an array

    Private Sub Categorybox_Change()
    Dim r As Integer
    Dim c As Integer
    c = 2
    r = 2
    x = 0
    TypeBox.Clear
    Do While Cells(r, c).Value <> categorybox.Value
    r = r + 1
    Loop
    Do While Cells(r, c) = categorybox.Value
    TypeBox.AddItem Cells(r, c + 1).Value
    r = r + 1
    Loop
    End Sub

    You don't gain anything significant from putting them in an array first.

    --
    Regards,
    Tom Ogilvy


    "musictech" <musictech.1sqlz0_1122314798.6839@excelforum-nospam.com> wrote
    in message news:musictech.1sqlz0_1122314798.6839@excelforum-nospam.com...
    >
    > Having a bit of trouble with the following code. I am attempting to
    > create a drop down box that contains the contents of a list of cells.
    > The cells aren't in a fixed location and there could be a different
    > number of items depending on another list box. So the array can't be a
    > fixed size. How can I add the items I want to the array and then
    > display them in the combobox?
    >
    > Thanks
    >
    >
    > Code:
    > --------------------
    > Private Sub Categorybox_Change()
    > Dim typ() As Integer
    > Dim x As Integer
    > Dim r As Integer
    > Dim c As Integer
    > c = 2
    > r = 2
    > x = 0
    >
    > Do While Cells(r, c) <> categorybox.Value
    > r = r + 1
    > Loop
    > Do While Cells(r, c) = categorybox.Value
    > ReDim typ(x + 1)
    > typ(x) = Cells(r, (c + 1))
    > x = x + 1
    > r = r + 1
    > Loop
    > Typebox.List = typ()
    > End Sub
    >
    > --------------------
    >
    >
    > --
    > musictech
    > ------------------------------------------------------------------------
    > musictech's Profile:

    http://www.excelforum.com/member.php...o&userid=24851
    > View this thread: http://www.excelforum.com/showthread...hreadid=389951
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1