LavendarRabbit
New Member
- Joined
- Apr 19, 2021
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Hello,
I have a MultiTab UserForm, and want to focus on the "Check" tab. Currently when the user types in the WO number into the ComboBox (ComboBox7), then clicks the command button with the magnifying glass (CommandButton3), it will search the "Paste Log" worksheet and pull the first line that matches the WO and pull in all of the corresponding information into the UserForm.
Since the "Paste Log" worksheet has duplicate WOs, I would like all of the other ComboBoxes on the Userform to include the applicable data from all of the lines that match the WO number.
Here are my 2 codes:
WO# = ComboBox7 = Col B
Magnifying Glass Command Button = CommandButton3
Type = ComboBox11 = Col A
Lot Code =ComboBox8 = Col C
IDH Code = ComboBox9 = Col D
Batch Code = ComboBox10 Col E
Paste Consistency = ComboBox16 = Col H
Note = TextBox12 = Col I
Employee = TextBox7 = Col J
Thank you in advance!
I have a MultiTab UserForm, and want to focus on the "Check" tab. Currently when the user types in the WO number into the ComboBox (ComboBox7), then clicks the command button with the magnifying glass (CommandButton3), it will search the "Paste Log" worksheet and pull the first line that matches the WO and pull in all of the corresponding information into the UserForm.
Since the "Paste Log" worksheet has duplicate WOs, I would like all of the other ComboBoxes on the Userform to include the applicable data from all of the lines that match the WO number.
Here are my 2 codes:
VBA Code:
Private Sub ComboBox7_Change()
Dim i As Long
Dim lr As Long
If ComboBox7 <> "" Then
With Sheets("Paste Log")
lr = .Cells(Rows.Count, "B").End(xlUp).Row
For i = 2 To lr
If InStr(1, .Cells(i, "B"), ComboBox7) > 0 Then
ComboBox7.AddItem .Cells(i, "B")
End If
Exit For
Next i
End With
End If
End Sub
VBA Code:
Private Sub CommandButton3_Click()
Dim Res As Long
Dim Found As Range
Dim lr As Long
Dim i As Long
Dim lngCounter As Long
Set Found = Sheets("Paste Log").Range("B:B").Find(What:=ComboBox7.Value, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
With Sheets("Paste Log")
lr = .Cells(Rows.Count, "B").End(xlUp).Row
For i = 2 To lr
If .Cells(i, "B") = ComboBox7 Then
Res = i
Exit For
End If
Next i
End With
If Not Found Is Nothing Then
Res = Found.Row
If Res <> 0 Then
ComboBox11.Value = Sheets("Paste Log").Range("A" & Res).Value
ComboBox8.Value = Sheets("Paste Log").Range("C" & Res).Value
ComboBox9.Value = Sheets("Paste Log").Range("D" & Res).Value
ComboBox10.Value = Sheets("Paste Log").Range("E" & Res).Value
ComboBox6.Value = Sheets("Paste Log").Range("H" & Res).Value
TextBox12.Value = Sheets("Paste Log").Range("I" & Res).Value
TextBox7.Value = Sheets("Paste Log").Range("J" & Res).Value
Else
MsgBox "WO does not exist. Verify WO is typed in correctly, otherwise contact supervisor", , ""
End If
End If
End Sub
WO# = ComboBox7 = Col B
Magnifying Glass Command Button = CommandButton3
Type = ComboBox11 = Col A
Lot Code =ComboBox8 = Col C
IDH Code = ComboBox9 = Col D
Batch Code = ComboBox10 Col E
Paste Consistency = ComboBox16 = Col H
Note = TextBox12 = Col I
Employee = TextBox7 = Col J
Thank you in advance!