Populate List Box Text Box with Excel Data Using VBA

How to Populate Listbox and Textboxes with Excel data using VBA
A question asked by one of our website visitors:
How to populate a list box and text boxes using data from an Excel worksheet using VBA. I have a user form with an optionbutton and 2 text boxes.
(1) Once I click on the option button ‘fans’ I wish that my list box gets populated with data from the ‘fans’ column.
(3) When I select a model I wish that the diameter of the fans and their wattage appears in the corresponding text boxes.
How can this be done quickly and easily?

Code for the optionbutton:
Private Sub OptionButton1_Change()
Me.ListBox1.RowSource = “A2: A5”
End Sub

Code for the Listbox:
Private Sub ListBox1_Change()
TextBox1.Value = Application.VLookup(Me.ListBox1, Sheets(“Sheet1”).Range(“A:C”), 2, False)

TextBox2.Value = Application.VLookup(Me.ListBox1, Sheets(“Sheet1”).Range(“A:C”), 3, False)
End Sub

Code for the commandbutton:
Private Sub CommandButton1_Click()
End Sub

Watch the video (21 MB) below to see the solution:

4 thoughts on “Populate List Box Text Box with Excel Data Using VBA”

  1. Hello sir, firstly I would like to say thank-you for providing such a helpful videos.

    Sir I’m facing problem in filtering in list box. As I’ve a spreadsheet containing receipt no. school id and some more details about fee details. So I want to filter all the details in list box having same school id .
    so please help me. I’ve tried but can’t find.

  2. Sir,

    My query regarding using vlookup with match function together using macro

    I want to copy entire table from sheet 2 to sheet 1 using matching column heading as well as raw heading. Macro should be in such a way that if i change any heading of column or raw, in sheet 1 the value input from sheet 2 automatically placed correctly in sheet 1

    Need your help


    1. Dear Sir,

      Thank you very much for your very professional explained tutorials. Based on your various episodes I am in the process of developing my personal Invoice template.

      I am stucked with some issue with combo box & its linked next user from item.

      1. I want my combo box to show list at the time I start typing in it. This will help me to make sure that I am selecting right data option.

      2. I have data list having three columns. CustID, Customer Name & BillingID (ie.applicable rates). Once I select CustID in earlier user form field, the next item on user form should sort list of applicable rates to that customer only. So that we can minimise choices & get the exact applicable rate for that customer. As I have more than 60 customer list with more than 40 rate items. It is very tidy work to select avalable option using simple combo box setting. I seen your earlier video but if we can configure these two items then it will become more user friendly form for data entry. Please help me with solution.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.