Hi,
Can anyone help, i am trying to get a msgbox to popup when no id is found.
I have a sheet called Info and in column G i have some names and in column H I have some id numbers.
I have a userformwith two textboxes when i scan an id into textbox7 that then searches the sheet
Info then populates textbox8 with the name in column G opposite that then puts textbox8 value into column H on the active
sheet which all works fine. What i would like is for a msgbox to popup if no id is found in column H
on the Info sheet. I am all new to this so any help would be great. Here is what I have at the minute.
Hope this makes sense.
Private Sub TextBox7_Change()
Dim i As Long, LastRow As Long
LastRow = Sheets("Info").Range("H" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Sheets("Info").Cells(i, "H").Value = (Me.TextBox7) Or _
Sheets("Info").Cells(i, "H").Value = Val(Me.TextBox7) Then
Me.TextBox8 = Sheets("Info").Cells(i, "G").Value
End If
Next
End Sub
Private Sub TextBox8_Enter()
Application.DisplayAlerts = False
Dim LastRow As Long, ws As Worksheet
Set ws = ActiveSheet
LastRow = ws.Range("H" & Rows.Count).End(xlUp).Row + 1
ws.Range("H" & LastRow).Value = TextBox8.Text
TextBox7.Value = ""
TextBox8.Value = ""
Application.DisplayAlerts = True
Unload out2
out3.Show
End If
End Sub
Regards
Can anyone help, i am trying to get a msgbox to popup when no id is found.
I have a sheet called Info and in column G i have some names and in column H I have some id numbers.
I have a userformwith two textboxes when i scan an id into textbox7 that then searches the sheet
Info then populates textbox8 with the name in column G opposite that then puts textbox8 value into column H on the active
sheet which all works fine. What i would like is for a msgbox to popup if no id is found in column H
on the Info sheet. I am all new to this so any help would be great. Here is what I have at the minute.
Hope this makes sense.
Private Sub TextBox7_Change()
Dim i As Long, LastRow As Long
LastRow = Sheets("Info").Range("H" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Sheets("Info").Cells(i, "H").Value = (Me.TextBox7) Or _
Sheets("Info").Cells(i, "H").Value = Val(Me.TextBox7) Then
Me.TextBox8 = Sheets("Info").Cells(i, "G").Value
End If
Next
End Sub
Private Sub TextBox8_Enter()
Application.DisplayAlerts = False
Dim LastRow As Long, ws As Worksheet
Set ws = ActiveSheet
LastRow = ws.Range("H" & Rows.Count).End(xlUp).Row + 1
ws.Range("H" & LastRow).Value = TextBox8.Text
TextBox7.Value = ""
TextBox8.Value = ""
Application.DisplayAlerts = True
Unload out2
out3.Show
End If
End Sub
Regards