jason77
07-07-2018, 06:40 AM
Hello I am trying to figure out how to make the following code work. I want to have users be able to create their own list to keep track of issues, and when they choose the issue it will auto fill the textboxs for them.
Sub OpenForm()
UserForm1.Show
UserForm1.ComboBox1.SetFocus
End Sub
Private Sub UserForm_Initialize()
Dim xRg As Range
Set xRg = Worksheets("Sheet2").Range("A2:F1000")
ComboBox1.List = xRg.Columns(1).Value
ComboBox6.AddItem "Associate"
ComboBox6.AddItem "Contactor"
ComboBox6.AddItem "Vendor"
ComboBox7.AddItem "EST"
ComboBox7.AddItem "PST"
ComboBox7.AddItem "CST"
ComboBox7.AddItem "MST"
ComboBox7.AddItem "AST"
ComboBox7.AddItem "AKST"
ComboBox7.AddItem "IST"
End Sub
Private Sub ComboBox1_Change()
TextBox1.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, [xRg], 2)
TextBox20.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 4, False)
TextBox21.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 3, False)
TextBox22.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 5, False)
TextBox23.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 6, False)
End Sub
Sub OpenForm()
UserForm1.Show
UserForm1.ComboBox1.SetFocus
End Sub
Private Sub UserForm_Initialize()
Dim xRg As Range
Set xRg = Worksheets("Sheet2").Range("A2:F1000")
ComboBox1.List = xRg.Columns(1).Value
ComboBox6.AddItem "Associate"
ComboBox6.AddItem "Contactor"
ComboBox6.AddItem "Vendor"
ComboBox7.AddItem "EST"
ComboBox7.AddItem "PST"
ComboBox7.AddItem "CST"
ComboBox7.AddItem "MST"
ComboBox7.AddItem "AST"
ComboBox7.AddItem "AKST"
ComboBox7.AddItem "IST"
End Sub
Private Sub ComboBox1_Change()
TextBox1.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, [xRg], 2)
TextBox20.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 4, False)
TextBox21.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 3, False)
TextBox22.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 5, False)
TextBox23.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 6, False)
End Sub