You could put this in the userform's code module
and call the userform with code likePrivate Sub CommandButton1_Click() Me.Hide End Sub
Sub test() Dim uiValue As String UserForm1.Show uiValue = UserForm1.TextBox1.Text Unload UserForm1 If uiValue = vbNullString Then MsgBox "user entered nothing" Else MsgBox "user entered " & uiValue End If End Sub