Thread: Exit Sub?
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 1,327
Default Exit Sub?

Hi

Part answer only:
You want a macro to return an "OK, go on", if not do not run the other macros ? Macros
that return something are Functions. Or better; macros are functions that return nothing,
"Void" in other programming languages. See if this sample can be of use -run Main:

Sub Main()
If Something = True Then
Call Anything
Call Everything
End If
End Sub

Function Something() As Boolean
Something = False
If InputBox("Enter something:") < "" Then _
Something = True
End Function

Sub Anything()
MsgBox "Anything goes"
End Sub

Sub Everything()
MsgBox "Everything goes"
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Eva Shanley" wrote in message
...
Hello, I could use some help with my code. This code
checks to make sure there are dates in Col. E for every
every entry in Col. C. The first problem I have is if I
click OK in the MsgBox and OK in the InputBox, the macro
stops without forcing me to enter a date. The second
problem is that I'd like this macro to execute first, then
call several others. Even if this macro stops executing,
the others behind it run. It doesn't look like Exit Sub
will do what I need either, and if a date is missing in
Col. E, I really need to force the user to input the date,
have the date check macro finish checking Col. E, and then
call the other macros. What am I missing (maybe Santa will
bring me a brain)? Any help will be much appreciated!

Sheets("Pacc AD").Select
Range("C24").Select
Dim Value1
Do Until ActiveCell = ""

If ActiveCell < "" And ActiveCell.Offset(0, 2) < "" Then
ActiveCell.Offset(1, 0).Select

Else: Check = MsgBox("Missing date in Column E!",
vbCritical, "Please check your dates!")
ActiveCell.Offset(0, 2).Select
Value1 = InputBox("Enter the missing date")
ActiveCell.FormulaR1C1 = Value1
ActiveCell.Offset(1, -2).Range("A1").Select

End If
Loop
End Sub