ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Input Box (https://www.excelbanter.com/excel-programming/373997-input-box.html)

steven

Input Box
 
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.

Dave Peterson

Input Box
 
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).

Steven wrote:

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.


--

Dave Peterson

Zone

Input Box
 
If Response1 = vbYes Then
SaveUserName = InputBox("Enter User Name:")
if SaveUserName<"" then _
Range("RangeUserName") = "User: " + SaveUserName
End If
James

Steven wrote:
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.




All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com