PDA

View Full Version : Need help figuring this code out!



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

Paul_Hossler
07-07-2018, 07:50 PM
I added CODE tags to your macros to format and set them off -- you can use the [#] icon to insert a pair and paste your macro in between them the next time

You didn't say what is not working nor attach a sample workbook showing the issue, so this is just a guess




TextBox1.Text = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, xRg, 2, False)

Fluff
07-08-2018, 10:45 AM
Another guess move this line
Dim xRg As Rangeto the very top of the module, before any code