Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How to Kill a vba macro from a Function//

This macro check all cells in columns A; in my VBA a Module call a Function
and it runs after all cell values in column A has been checked. During the
process It prompts with a MsgBox if this cell has errors ONLY (this MsgBox is
inside this Function).

if this CELL has errors. I want to add in this MsgBox an option to:

Yes:GOTO cell with errors and then CLOSE vba macro OR
No: continue with the loop checking all values in column A.

My question is:
There is a command that I can put inside a function to kill or force the
Macro to end?

I tried

"End Function"

but it kills only the function and not the entire forms (3 forms)


Thanks

Coco
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to Kill a vba macro from a Function//


Coco,
Just use

End

that will End the function and the macro which called it.

HTH


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=381767

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default How to Kill a vba macro from a Function//

That also clears any persistent variables (public/static).

You may want to use this very sparingly (or not at all).

bhofsetz wrote:

Coco,
Just use

End

that will End the function and the macro which called it.

HTH

--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=381767


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default How to Kill a vba macro from a Function//

I'd pass back the results of the function. Kind of like:

sub testme

dim OkToContinue as boolean
okTocontinue = dosomething(activesheet.range("a1:A10"))

if oktocontinue = false then
exit sub
end if

oktocontinue = dosomethingelse(...)

'....

end sub

function dosomething(rng as range) as boolean
dim res as long
'do something
res = msgbox(prompt:="continue?",buttons:=vbyesno)
if res = vbyes then
dosomething = true
else
dosomething = false
end if
end function



coco wrote:

This macro check all cells in columns A; in my VBA a Module call a Function
and it runs after all cell values in column A has been checked. During the
process It prompts with a MsgBox if this cell has errors ONLY (this MsgBox is
inside this Function).

if this CELL has errors. I want to add in this MsgBox an option to:

Yes:GOTO cell with errors and then CLOSE vba macro OR
No: continue with the loop checking all values in column A.

My question is:
There is a command that I can put inside a function to kill or force the
Macro to end?

I tried

"End Function"

but it kills only the function and not the entire forms (3 forms)

Thanks

Coco


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How to Kill a vba macro from a Function//

Excellent!!. It works that way!

Thank you for the approach

Coco


"coco" wrote:

This macro check all cells in columns A; in my VBA a Module call a Function
and it runs after all cell values in column A has been checked. During the
process It prompts with a MsgBox if this cell has errors ONLY (this MsgBox is
inside this Function).

if this CELL has errors. I want to add in this MsgBox an option to:

Yes:GOTO cell with errors and then CLOSE vba macro OR
No: continue with the loop checking all values in column A.

My question is:
There is a command that I can put inside a function to kill or force the
Macro to end?

I tried

"End Function"

but it kills only the function and not the entire forms (3 forms)


Thanks

Coco

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
Kill Macro Jeff Excel Discussion (Misc queries) 4 September 27th 06 04:33 PM
On time kill Antonio Excel Discussion (Misc queries) 4 June 8th 06 10:50 AM
'Kill' solomon_monkey Excel Programming 7 January 7th 05 09:56 AM
File kill help Marino13[_6_] Excel Programming 0 February 19th 04 01:40 PM
AutoFill KILL Frustrated[_2_] Excel Programming 1 July 29th 03 04:40 PM


All times are GMT +1. The time now is 08:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"