Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default '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   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default '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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prompt user to select a printer using a checkbox within a user Tom Ogilvy Excel Programming 0 January 10th 07 03:57 AM
Cancel 'Password' prompt during VBA Shimmess Excel Programming 7 December 28th 06 03:50 AM
VBScript to prompt Save on Cancel click paperclip[_2_] Excel Programming 8 August 3rd 06 04:11 PM
How to CANCEL file SAVE PROMPT when MACRO is running? Stuart Macro Muppet Excel Discussion (Misc queries) 3 August 11th 05 12:26 PM
Cancel Macro is user selects 'cancel' at save menu Mark Excel Programming 1 April 6th 05 05:45 PM


All times are GMT +1. The time now is 07:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"