View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
IT_roofer IT_roofer is offline
external usenet poster
 
Posts: 45
Default A Sub/Function to cause another Sub/Function to Exit

"Tom Ogilvy" wrote:

Perhaps something like this:

Sub DumpData()

' existing code
if not newCell then exit sub
' existing code

End sub


Function newCell() as Boolean
Dim whiteSpace As Object
Dim curCell As Integer

Set whiteSpace = CreateObject("VBScript.RegExp")
whiteSpace.IgnoreCase = True
whiteSpace.Pattern = "^\s*$"

If ActiveSheet.name < "myForm" Then Sheet2.Activate
If Not ActiveCell.Address = "$L$19" Then Range("L19").Select

For curCell = 19 To 45
cells(curCell,"L").Select
If (whiteSpace.test(ActiveCell.value)) Then
NewCell = True
ElseIf curCell = 45 Then
MsgBox "No more line entries available." & _
Chr(13) & "Please combine your entries and resubmit."
NewCell = False
End If
Next
NewCell = True
End Function

--
Regards,
Tom Ogilvy



Thank you for the suggestion. I will try it. One question: doesn't the
"NewCell = True" statement at the end override the "NewCell = False"
statement in the "ElseIf curCell = 45" - or is that just to reset "NewCell"
when the For loop is over?