Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
double bar graph help | Charts and Charting in Excel | |||
double axis, double problem (i hope only to me) | Charts and Charting in Excel | |||
Double IF - is this possible | Excel Worksheet Functions | |||
Double spacing | Excel Discussion (Misc queries) | |||
Need Function for Double If | Excel Worksheet Functions |