+ Reply to Thread
Results 1 to 3 of 3

VBA Userform: Use value from Comobox to populate a Listbox

  1. #1
    Registered User
    Join Date
    02-23-2013
    Location
    ichprsi and
    MS-Off Ver
    Excel 2003
    Posts
    2

    VBA Userform: Use value from Comobox to populate a Listbox

    1st of all let me say that over the past year or so I've found many answers to many questions about Excel browsing your forums. This site has been a tremendous help. Prior to 18 months ago I never touched Excel. In my mind it was nothing more than glorified app for making tables. However after taking a job as a PA with a company that is very "old school" in it's practices (I still have a stack of carbon copy order forms I use often) and after weighing several options & arriving at dead-ends, I realized Excel was my best option.

    Less than a year ago I purchased the "purchase_order_manager" from Vertex42 for $15 and I've been on my way ever since. I've modified the thing to death & over time I've realized that there's so much more I could be doing and automating with Excel. For that reason I've begun working on my workbook for managing inventories & orders.

    I've recently stumbled across a wonderful thing in VBA called "Userforms" which have opened a tremendous amount of possibilities with what I want to do. I'm very new to Excel let alone VBA. I know my around (enough to get into trouble) php code & some other languages & I'm typically pretty good at figuring things out however I've scoured forums, tutorials, videos & books for the past few days & I'm absolutely stuck....

    What I'm working on... I have 2 worksheets in my workbook one named "Vendors" which is essentially a database of all the companies I buy materials from. The second sheet is called "Stock" which is a database of all the parts I buy from all vendors.


    User Clicks "Create Order" button which brings up a form

    User Selects "Vendor" form a combobox which has the RowSource property of "Vendors!VendorName" (VendorName is the name of the 1st column of that sheet)

    When a vendor is selected in the combobox, the listbox below would populate with all the parts from the sheet "Stock" that belong to that vendor. User can then select or multiselect the parts to add to the order.

    Clipboard02.jpgClipboard01.jpg

    As you can see I can obviously get the parts listed in the listbox but I havent a clue how to display only ones by selected vendor. I really have no code thus far to share either.

    Thanks in advance.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA Userform: Use value from Comobox to populate a Listbox

    This uses the Autofilter feature to filter the Stock sheet for the selected Vendor, and then populates Listbox1 on the filtered result. It assumes your Vendors are sorted so each vendor is in contiguous rows (grouped).

    Note: Do not set a RowSource for the Listbox. The code populates it.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 11-22-2013 at 02:38 AM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    02-23-2013
    Location
    ichprsi and
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: VBA Userform: Use value from Comobox to populate a Listbox

    Worked like a charm! Thank you so much AlphaFrog

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Populate VBA Userform Listbox using SQL Recordset
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2013, 06:48 PM
  2. VBA - Populate Listbox based on value selected in another ListBox (On Userform)
    By raaboo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-12-2012, 11:18 AM
  3. Populate userform listbox based on value selected in another listbox
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-07-2012, 05:16 PM
  4. how to populate Listbox on userform
    By kmsoni in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-22-2011, 02:13 PM
  5. Populate userform listbox from access db
    By Nancy Moon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-01-2006, 05:25 PM

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