Results 1 to 2 of 2

listbox add item

This is a discussion on listbox add item within the Excel Questions forums, part of the Question Forums category; Hi there, Looking for help on a custome user form. Have a drop down controll that with 3 values hard ...

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    232

    Default listbox add item

    Hi there,

    Looking for help on a custome user form.

    Have a drop down controll that with 3 values hard coded in (ie JAX,TIZ,OAP)

    Based on the selected item from the above code, I want to fill a list box with associated items (from a range with in the workbook ie sheet1 A1:B10-A1:A10 being one of the 3 hard coded items, b1:b10 being the related items.

    I've tried ListBox1.AddItem from the help files, but seem to be getting no where fast.

    Any clues on this one?
    Thanks in advance
    Matt

  2. #2
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    64,589

    Default Re: listbox add item

    Try this:

    Code:
    Private Sub ComboBox1_Change()
        Dim c As Range
        ListBox1.Clear
        For Each c In Worksheets("Sheet1").Range("A1:A10")
            If c.Value = ComboBox1.Value Then
                ListBox1.AddItem c.Offset(0, 1).Value
            End If
        Next c
    End Sub

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com