Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
'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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
'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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
'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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Prompt user to select a printer using a checkbox within a user | Excel Programming | |||
Cancel 'Password' prompt during VBA | Excel Programming | |||
VBScript to prompt Save on Cancel click | Excel Programming | |||
How to CANCEL file SAVE PROMPT when MACRO is running? | Excel Discussion (Misc queries) | |||
Cancel Macro is user selects 'cancel' at save menu | Excel Programming |