Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default return from subroutine

I have a program which calls a subroutine which in turn calls another
subroutine as in this schematic..

main program
call suba(z)
end
sub suba(z)
some code
call subb(x)
more code
end sub

sub subb(x)
some code
if x 100 then return
more code
end sub

When x 100 in subb, the progam returns to the main program and not to
suba.

Can someone tell me what I am doing wrong please?

Thanks
Chris







  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default return from subroutine

Hi Chris,

Try changing the line:

if x 100 then return
To:
if x 100 then exit sub

---
Regards,
Norman

"inquirer" wrote in message
...
I have a program which calls a subroutine which in turn calls another
subroutine as in this schematic..

main program
call suba(z)
end
sub suba(z)
some code
call subb(x)
more code
end sub

sub subb(x)
some code
if x 100 then return
more code
end sub

When x 100 in subb, the progam returns to the main program and not to
suba.

Can someone tell me what I am doing wrong please?

Thanks
Chris









  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default return from subroutine

I have a program which calls a subroutine which in turn calls another
subroutine as in this schematic..


When x 100 in subb, the progam returns to the main program and not to
suba.

Can someone tell me what I am doing wrong please?


try this:

Sub subb(x)
'some code
If x 100 Then End
'more code
End Sub

or:

Sub suba(z)
'some code
Call subb(x)
If x < 100 Then
'more code
End If
End Sub

Sub subb(x)
'some code
If x < 100 Then
'more code
End If
End Sub

--
Regards

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default return from subroutine

Simple when you know how - thanks a lot

Chris


"Melanie Breden" wrote in message
...
I have a program which calls a subroutine which in turn calls another
subroutine as in this schematic..


When x 100 in subb, the progam returns to the main program and not to
suba.

Can someone tell me what I am doing wrong please?


try this:

Sub subb(x)
'some code
If x 100 Then End
'more code
End Sub

or:

Sub suba(z)
'some code
Call subb(x)
If x < 100 Then
'more code
End If
End Sub

Sub subb(x)
'some code
If x < 100 Then
'more code
End If
End Sub

--
Regards

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)



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
Call a subroutine using variable subroutine name dhstein Excel Discussion (Misc queries) 3 July 26th 09 08:28 PM
SUBROUTINE HELP biker man Excel Discussion (Misc queries) 1 July 28th 07 04:06 PM
association of hot key with subroutine Walter-U. Kellner Excel Programming 2 April 14th 04 09:01 PM
editing a subroutine ChuckM[_2_] Excel Programming 2 January 12th 04 05:56 PM
Every second subroutine dolegow Excel Programming 1 October 12th 03 02:11 AM


All times are GMT +1. The time now is 01:10 PM.

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"