Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Listbox items (Office 2000)

    How do you load items into a Listbox.

    I want the user to do a selection from a listbox and then from his selection certain procudures should take place

    Second question: When I select the " sign I need to press space afterwards in order to show the ".


    Thanks

    Mario Smit

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Listbox items (Office 2000)

    Mario,

    Is you Listbox contained in a Worksheet or a UserForm(VBA) ?.
    If in a Worksheet, is it from the Control Toolsbox toolbar or from the Forms toolbar ?.
    If it is Userform, is the data to fill it held on a worksheet ?

    Could you elaborate more on the second quest about

  3. #3
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listbox items (Office 2000)

    The listbox is in a Userform. I don't wan't to use the rowsource property because the Code will not be linked to a specific workbook.

    On the " issue. If I press the " it doesn't show. Only after I press the " and space it appears. It seems like a specific setting in Office or Windows

    Thanks

    Mario

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listbox items (Office 2000)

    Hi Mario,

    <<On the " issue. If I press the " it doesn't show. Only after I press the " and space it appears. It seems like a specific setting in Office or Windows>>

    That is caused by your keyboard language setting. once you change it to English, you get your " immediately.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Listbox items (Office 2000)

    Mario,

    You can assign the values in an array to the List property of the listbox, in the UserForm Initialize or Activate events as follows :<pre> Me.ListBox1.List = MyArray</pre>

    where MyArray is an array which you have populated with the values required. Or you could use the AddItem method to assign the values individually as in <pre> Me.ListBox1.AddItem Value</pre>

    where Value is the item to add.

    If you want to assign the values outside of the Userform, you can replace Me with the Userform name.

    Hope that is of help.

    Andrew C

  6. #6
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listbox items (Office 2000)

    Please help with the coding. I'm lost with the array.

    I tried with:

    Sub pop_select initialise

    Thanks Jan Karel that solved my problem

    Mario
    dim alfab() as variant

    alfab() = array("a","b")

    ME.listbox1.list alfab

    end sub

  7. #7
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Listbox items (Office 2000)

    Mario,

    In the Userform Activate (or Initialize) event try <pre> Me.ListBox1.List = Array("a", "b", "c")</pre>

    Cut out the middle man (alfab)

    Does that help ?

    Andrew

  8. #8
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listbox items (Office 2000)

    Thanks here is the final code:

    Private Sub UserForm_Initialize()

    Dim FinYear As Variant

    FinYear = Array("2000", "2001", "2002")

    Me.ListBox_year.List = FinYear

    End Sub

    Mario

  9. #9
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Listbox items (Office 2000)

    Another Question:

    Is it possible to add to array, that is, if the user wants to add "2003" to the array and in effect change the macro to read FinYear = Array("2000", "2001", "2002","2003") next time he uses the macro?

    Thanks for all the help

    Mario

Posting Permissions

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