View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tim Zych Tim Zych is offline
external usenet poster
 
Posts: 389
Default Input Box Cancel function


Sub InputboxExample()

Dim vResult As Variant
vResult = InputBox("Enter a value")

If StrPtr(vResult) = 0 Then
' Cancel pressed
MsgBox "Cancel"
ElseIf vResult = "" Then
' Zero-length string entered
MsgBox "zls"
Else
' Some entry
MsgBox CStr(vResult)
End If

End Sub

--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility

"Munchkin" wrote in message
...
My input box works great when a user is filling in the info. But I also
want
to give them the option to press cancel if they made a mistake & don't
want
to proceed. If they press cancel I want Row 4 to be deleted & the macro
to
end. How to I do that?


Range("B4") = InputBox("ENTER YOUR NAME - Press 'Enter' when done")
Range("C4") = InputBox("ENTER THE DATE YOU NEED THE FILE BY - Press
'Enter' when done")

Range("B4").Select