Hello,
I have a userform with a search button. What I would like is a msgbox popup with lastrow input equal to Textbox1.value. Only thing is that the msgbox can only popup if there is no value on column 4 of the same last row. For example, Textbox1.value is 1234 and the last row that is equal to this value is 45. Then if cell D45 has no value, the msgbox should popup, otherwise if there is a value in cell D45 the msgbox should not popup.
I already have this code for looking up lastrow input that is equal to Textbox1.Value
I hope my question if clear enough and I hope it is possible to add this to the code I already have.
Thanks in advance!!
I have a userform with a search button. What I would like is a msgbox popup with lastrow input equal to Textbox1.value. Only thing is that the msgbox can only popup if there is no value on column 4 of the same last row. For example, Textbox1.value is 1234 and the last row that is equal to this value is 45. Then if cell D45 has no value, the msgbox should popup, otherwise if there is a value in cell D45 the msgbox should not popup.
I already have this code for looking up lastrow input that is equal to Textbox1.Value
Code:
Private Sub CommandButton1_Click()
Dim I As Long
Dim Lastrow As Long
Lastrow = Sheets("Blad1").Cells(Rows.Count, "A").End(xlUp).row
For I = Lastrow To 1 Step -1
If Sheets("Blad1").Cells(I, 1).value = TextBox1.value Then
MsgBox "In use by: " & (Sheets("Blad1").Cells(I, 2).value)
Exit Sub
End If
Next
End Sub
Thanks in advance!!