PC Review


Reply
Thread Tools Rate Thread

'Cancel' on User Prompt Box

 
 
kmzito@gmail.com
Guest
Posts: n/a
 
      12th May 2009
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
 
Reply With Quote
 
 
 
 
Bernie Deitrick
Guest
Posts: n/a
 
      12th May 2009
sUsername = InputBox(sPrompt, sTitle, sDefault)
If sUsername = "" Then
MsgBox "You cancelled"
Exit Sub
End If

HTH,
Bernie
MS Excel MVP



<(E-Mail Removed)> wrote in message
news:ab6ab98a-b8eb-464b-8c4e-(E-Mail Removed)...
> 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


 
Reply With Quote
 
FSt1
Guest
Posts: n/a
 
      12th May 2009
hi
capture the cancel event.
Sub kmzito()
Dim sUsername As String
Dim sPrompt As String

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

If sUserName = "" Then
MsgBox "nothing was entered." & vbNewLine & "process termiated!"
Exit Sub
Else
' the rest of your code here
End If

End Sub

regards
FSt1

"(E-Mail Removed)" wrote:

> 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
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to cancel parameter criteria if prompt is blank =?Utf-8?B?YWxla2ZlbHN0aW5lcg==?= Microsoft Access Queries 5 7th May 2007 03:53 AM
Cancel 'Password' prompt during VBA =?Utf-8?B?U2hpbW1lc3M=?= Microsoft Excel Programming 7 28th Dec 2006 03:50 AM
VBScript to prompt Save on Cancel click paperclip Microsoft Excel Programming 8 3rd Aug 2006 04:11 PM
cancel system login prompt Sam Microsoft Access ADP SQL Server 3 29th Nov 2005 04:10 PM
Cancel Macro is user selects 'cancel' at save menu =?Utf-8?B?TWFyaw==?= Microsoft Excel Programming 1 6th Apr 2005 05:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:46 AM.