You need to use IF THEN ELSE code.
Private Sub Add_Click()
If TextBox2.Value = "" Then
MsgBox "Please Enter a Group-Unit/Assembly/Componant"
else
ListBox1.AddItem TextBox2.Value
TextBox2.Value = ""
End If
End Sub
If you disable the button at design time and add this code to the change event of the textbox you can stop the user from clicking the button until the textbox has text.
On a userform with a textbox and commandbutton.
Private Sub TextBox1_Change()
CommandButton1.Enabled = Len(Trim(TextBox1.Text)) > 0
End Sub
Bookmarks