ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   'Cancel' on User Prompt Box (https://www.excelbanter.com/excel-programming/428336-cancel-user-prompt-box.html)

[email protected]

'Cancel' on User Prompt Box
 
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

Bernie Deitrick

'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



FSt1

'Cancel' on User Prompt Box
 
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

" 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



All times are GMT +1. The time now is 05:27 PM.

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