Input Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If I do this:

If Response1 = vbYes Then
SaveUserName = InputBox("Enter User Name:")
Range("RangeUserName") = "User: " + SaveUserName
End If

How do I catch if the Cancel button was pressed and therefore don't do
anything?

Thank you for your help.

Steven.
 
If Response1 = vbYes Then
SaveUserName = InputBox("Enter User Name:")
if saveusername = "" then
'do what you want
else
Range("RangeUserName") = "User: " & SaveUserName
end if
End If


ps. It's probably a good habit to use & to concatenate text (and + to sum
numbers).
 
If Response1 = vbYes Then
SaveUserName = InputBox("Enter User Name:")
if SaveUserName<>"" then _
Range("RangeUserName") = "User: " + SaveUserName
End If
James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top