Fill Userform with Values VBA

The program below shows you how to add values to a listbox in a userform with Excel VBA.

Code:

Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub ListBox1_Click()
If ListBox1.Value = "Student 1" Then
Range("O1").Value = 1
End If
End Sub


Private Sub UserForm_Initialize()
UserForm1.ListBox1.RowSource = Range("StudentList").Address

'OR me.listbox1.rowsource = range("studentList").address
End Sub

Userform lesson:

You can watch my advanced mouse control to watch me turn a userform into a user input recorder:

You can also use an index formula like I do in Cell F102 and nearby cells to fill in however many cells into static areas based on userform selections. Just click the Charge Chart in the below workbook to change the stock chart to whichever stock is in my listbox. You can adjust the years of the Balance Sheets etc.

Comments are closed.