Can anyone help me with a user form coding.
I have a combo box that provides sheet names of a workbook. When select the sheet name the combobox fills my textboxes with data from the selected sheet. However in textbox 1 I have an employee name and my problem is that the data in the other textboxes are not for the specified value in textbox 1. Is there any way or can anyone help me with a vb code that can have the textboxes values match the search value in textbox1?
I've also attached the workbook with the userform.
Below is the code I am using:
Private Sub ComboBox1_Change()
Dim Ws As Worksheet, wb As Workbook
Set Ws = ActiveWorkbook.Sheets(ComboBox1.Value)
ComboBox1.Value = Ws.Name
TextBox1.Text = TextBox1.Text
Dim strSheet As String
If ComboBox1.ListIndex > -1 Then
strSheet = ComboBox1
Sheets(strSheet).Select True
Application.ScreenUpdating = False
If ComboBox1.Value = Ws.Name Then
If TextBox1.Text = TextBox1.Text Then
ID_tb.Text = Range("C" & ComboBox1.ListIndex + 7)
program_tb.Text = Range("B" & ComboBox1.ListIndex + 7)
Schedules_tb.Text = Range("E" & ComboBox1.ListIndex + 7)
StartTime_tb.Text = Range("F" & ComboBox1.ListIndex + 7)
EndTime_tb.Text = Range("G" & ComboBox1.ListIndex + 7)
Duration_tb.Text = Range("H" & ComboBox1.ListIndex + 7)
SysProb_tb.Text = Range("O" & ComboBox1.ListIndex + 7)
Break_tb.Text = Range("I" & ComboBox1.ListIndex + 7)
Break2_tb.Text = Range("J" & ComboBox1.ListIndex + 7)
Lunch_tb.Text = Range("K" & ComboBox1.ListIndex + 7)
OTBreak_tb.Text = Range("L" & ComboBox1.ListIndex + 7)
OTLunch_tb.Text = Range("M" & ComboBox1.ListIndex + 7)
Unsch_tb.Text = Range("N" & ComboBox1.ListIndex + 7)
End If
End If
End If
End Sub
Bookmarks