View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bruce Roberson[_2_] Bruce Roberson[_2_] is offline
external usenet poster
 
Posts: 23
Default Can't get out of loop at the right point

When I say quit, I don't mean I wanted to do a quit.applicatioin, since that
would exit Excel.
"Bruce Roberson" wrote in message
...
I need to know how to exit the sub in the case below in
sub submonth at the end of this section.

Basically when the IF statement here is:
If Range("Row").Value Range("DataRows").Value Then
Exit Sub

The command to "exit sub" just sends me back to the
calling sub detailloop and the command line "next" is
encountered in this situation.

Is there a command such as "quit" that allows it to not go
back to the calling sub in this case?



Sub Process_data()
Things happen here only once then
Call HeaderRecord
End Sub

Sub HeaderRecord()
Loops and Things happen here then
Call detailloop
End Sub

Sub detailloop()
looping going on here then

If Range("Row").Value Range("DataRows").Value Then
Call summonth
Else
If Range("New_Prmo") Then
Call summonth

Else
End If
End If
Next (refers to a loop that is not shown in this post)
End Sub

Sub summonth()
Range("rowsum").Value = Range("Rowsum").Value + 1
If Range("Row").Value Range("DataRows").Value Then
Exit Sub
Else
Call HeaderRecord
End If
End Sub