View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default 'Cancel' on User Prompt Box

sUsername = InputBox(sPrompt, sTitle, sDefault)
If sUsername = "" Then
MsgBox "You cancelled"
Exit Sub
End If

HTH,
Bernie
MS Excel MVP



wrote in message
...
Good evening,

When the 'Please Enter Vendor Name" prompt appears it gives you 'Ok'
and 'Cancel'. If you press okay it cycles through the way it should
but when you press cancel, it automatically goes to the first blank
row and asks you if this is correct. I'd like it to be if you press
cancel, that's it, No more!


Dim sUsername As String
Dim sPrompt As String

sPrompt = "Please enter vendor name"
sUsername = InputBox(sPrompt, sTitle, sDefault)

Sheets("list").Select
Range("d4").Select
Cells.Find(What:=sUsername, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Select

Answer = MsgBox("Is this the contract/vendor you would like to
delete?", vbYesNo + vbInformation, "Please Confirm")
If Answer = vbYes Then
Selection.EntireRow.Delete

Exit Sub