#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Exit Sub?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Exit Sub?

Hi

I am sure there is a better way to do this, but just modifying your code a
little like this using columns D and E seems to work ok.


Sheets("Pacc AD").Select
Range("D1").Select

Dim Value1
Dim check As Integer

Do Until ActiveCell = ""

If ActiveCell.Offset(0, 1) = "" Then

check = MsgBox("Missing date in Column E!", vbOKCancel + vbCritical, "Please
check your dates!")
If check = vbCancel Then Exit Sub

tryagain:

Value1 = InputBox("Enter the missing date using the format....
DD/MM/YYYY")

If Value1 = "" Then
MsgBox "You must enter a date like.... 29/05/2004"
GoTo tryagain
End If

ActiveCell.Offset(0, 1).Value = Value1


End If

ActiveCell.Offset(1, 0).Select
Loop
End Sub


HTH

Ken


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Exit Sub?

Thanks to both of you for your input!

-----Original Message-----
Hi

I am sure there is a better way to do this, but just

modifying your code a
little like this using columns D and E seems to work ok.


Sheets("Pacc AD").Select
Range("D1").Select

Dim Value1
Dim check As Integer

Do Until ActiveCell = ""

If ActiveCell.Offset(0, 1) = "" Then

check = MsgBox("Missing date in Column E!", vbOKCancel +

vbCritical, "Please
check your dates!")
If check = vbCancel Then Exit Sub

tryagain:

Value1 = InputBox("Enter the missing date using the

format....
DD/MM/YYYY")

If Value1 = "" Then
MsgBox "You must enter a date like.... 29/05/2004"
GoTo tryagain
End If

ActiveCell.Offset(0, 1).Value = Value1


End If

ActiveCell.Offset(1, 0).Select
Loop
End Sub


HTH

Ken


.

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
Cancel/Exit Sub Howard Excel Discussion (Misc queries) 3 December 16th 08 09:53 PM
Exit Sub Jeff Excel Discussion (Misc queries) 2 March 1st 08 06:21 PM
Excel 07 won't exit Elle Setting up and Configuration of Excel 0 July 27th 07 12:40 AM
Run when exit PH NEWS Excel Worksheet Functions 1 July 18th 06 03:53 PM
Exit via macro only? Brisbane Rob Excel Discussion (Misc queries) 1 October 13th 05 01:16 PM


All times are GMT +1. The time now is 12:35 AM.

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

About Us

"It's about Microsoft Excel"