Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default End Double Sub


I'm having difficulties Ending a macro.

a Sub calls an other Sub that also investigates if a value alread
exists in a range of cells. If it doesnt exist, the main sub can go on
*else both Subs has to end*

The last part doesn work, i can only stop the sub I'm working in.

How to solve this problem?

Th

--
Zur
-----------------------------------------------------------------------
Zurn's Profile: http://www.excelforum.com/member.php...fo&userid=1464
View this thread: http://www.excelforum.com/showthread.php?threadid=26724

  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default End Double Sub

hi,
not sure because i haven't seen your code but i would say
combine the two macros. put the called macro inside the
main macro as an if then else. that way you only have 1
macro to stop.

-----Original Message-----

I'm having difficulties Ending a macro.

a Sub calls an other Sub that also investigates if a

value already
exists in a range of cells. If it doesnt exist, the main

sub can go on,
*else both Subs has to end*

The last part doesn work, i can only stop the sub I'm

working in.

How to solve this problem?

Thx


--
Zurn
----------------------------------------------------------

--------------
Zurn's Profile: http://www.excelforum.com/member.php?

action=getinfo&userid=14645
View this thread:

http://www.excelforum.com/showthread...hreadid=267249

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default End Double Sub

Change your procedure from a sub routine to a function.
Make the return type a Boolean then return true if found
and false in not.

The function would look sometjhing like the following.
This function will seach a column (column C in the
spreadsheet) from row 10 to row 20. If it finds the value
it exits the function and returns True. If it completes
the search without finding the item, it exits the function
and returns false.

Public Function mysearch(myParam As myParamType) As Boolean
curRow=10
maxRow=20
myCol=3

Do While curRow < maxRow
mVal=worksheets(1).cells(curRow, myCol).value
if(myVal=myParam)then
mysearch=True
exit sub
endif

curRow=curRow+1

loop

mysearch=False

end function

In your calling function have the following code:

if(not mysearch(desiredValue))then
exit sub
endif

I hope that is clear.

Kevin
-----Original Message-----

I'm having difficulties Ending a macro.

a Sub calls an other Sub that also investigates if a

value already
exists in a range of cells. If it doesnt exist, the main

sub can go on,
*else both Subs has to end*

The last part doesn work, i can only stop the sub I'm

working in.

How to solve this problem?

Thx


--
Zurn
----------------------------------------------------------

--------------
Zurn's Profile: http://www.excelforum.com/member.php?

action=getinfo&userid=14645
View this thread:

http://www.excelforum.com/showthread...hreadid=267249

.

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
double bar graph help brittany Charts and Charting in Excel 1 February 29th 08 08:57 AM
double axis, double problem (i hope only to me) kitcho Charts and Charting in Excel 1 December 30th 06 12:52 AM
Double IF - is this possible Alan Davies Excel Worksheet Functions 3 May 17th 06 10:44 AM
Double spacing axissm Excel Discussion (Misc queries) 2 February 19th 06 11:45 PM
Need Function for Double If Jones Excel Worksheet Functions 2 July 12th 05 09:14 PM


All times are GMT +1. The time now is 10:33 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"