LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Cancelling But Macro Still Carries On

Good afternoon all,

I have the below macro. I entered an addition line for when the user
presses the cancel box, but the macro keeps going after I press
cancel. I'd like it to stop and go back to the main menu.


SORT_VENDOR

Dim sUsername As String
Dim sPrompt As String

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

Sheets("list").Select
Range("C3").Select
Cells.Find(What:=sUsername, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Select
If sUsername = "" Then
MsgBox "You cancelled the search."
Sheets("welcome").Select
Range("a1").Select

Exit Sub

Answer = MsgBox("Is this the contract/vendor you would like to
delete?", vbYesNo + vbInformation, "Please Confirm")
If Answer = vbYes Then
Select Case LCase(Range("B" & Selection.Row).Value)

Case "monthly"
Selection.Resize(12, 1).EntireRow.Delete
Case "quarterly"
Selection.Resize(4, 1).EntireRow.Delete
Case "yearly"
Selection.EntireRow.Delete
End Select
Exit Sub

Else
Cells.Find(What:=sUsername, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
End If

DELETE_EMPTYROWS
 
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
Cancelling AutoFilter in a macro Floss Excel Programming 3 August 19th 08 06:54 PM
Text does not carries Over Godwin Chan Excel Worksheet Functions 3 July 7th 08 10:13 AM
Stop text carries over Godwin Chan Excel Worksheet Functions 3 July 4th 08 10:16 AM
Cancelling a macro Naive Excel Programming 1 March 16th 05 03:29 PM
end Macro after cancelling open dialog No Name Excel Programming 1 June 29th 04 08:58 AM


All times are GMT +1. The time now is 12:26 PM.

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"