+ Reply to Thread
Results 1 to 2 of 2

ListBox (?) in a macro

  1. #1
    aca
    Guest

    ListBox (?) in a macro


    I need, in a macro, an instruction that will display a long list from
    which the user can select an item and paste it into the current Active
    Cell.
    For approaching the item wanted I envisage one of those boxes with a
    one-line window, on top of it, for the user to type in characters
    belonging to the item he wants, so that with each character typed the
    selection bar within the box moves closer and closer to that item.
    Many thanks in advance to any good samaritan who can help.
    ACA


    --
    aca
    ------------------------------------------------------------------------
    aca's Profile: http://www.msusenet.com/member.php?userid=3856
    View this thread: http://www.msusenet.com/t-1873714044


  2. #2
    Forum Contributor
    Join Date
    01-10-2006
    Location
    Ahmedabad, India
    MS-Off Ver
    Office 2000
    Posts
    346
    You need a comboBox. Insert UserForm ( RightClick VBAProject(WorkBook1)>Insert Form ). When UserForm1 appears, put a ComboBox on the form from the tools menu that appears. You have thus designed your form. Put some code like this on your FormCodeSheet to populate the item list of the ComboBox.

    Private Sub Userform_initialize()
    ComboBox1.AddItem "ITEM1"
    ComboBox1.AddItem "ITEM2"
    ComboBox1.AddItem "ITEM3"
    ComboBox1.AddItem "ITEM4"
    ComboBox1.AddItem "ITEM5"
    ComboBox1.AddItem "ITEM6"
    End Sub


    You also need to have a sub to capture the data user selects from ComboBox . This could be

    Private Sub combobox1_change()
    UserData=ComboBox1.Text
    End Sub

    Both these Subs are on FormCodeSheet

    You will need one statement in your procedure to display the form

    UserForm1.Show

    This will display the form with the ComboBox. User then selects the data he wants which you capure as ComboBox1.Text. You can hide the form immediately by

    UserForm1.Hide

    Best Luck

    A V Veerkar
    Last edited by avveerkar; 01-27-2006 at 08:51 AM.

+ 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