+ Reply to Thread
Results 1 to 15 of 15

Quick beginner question-Why doesn't On Error Exit Function work?

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Quick beginner question-Why doesn't On Error Exit Function work?

    Just a quick question that's stumping me. I have boolean functions. Whenever I enter '
    Please Login or Register  to view this content.
    ' I get a syntax error. Why?
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    You cannot use Exit function with On Error.

    Instead try like this...

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    Quote Originally Posted by :) Sixthsense :) View Post
    You cannot use Exit function with On Error.

    Instead try like this...

    Please Login or Register  to view this content.
    Thanks. That's what I have been doing.

    But why can't you use Exit Function on Functions?

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    As far as I know there is only 3 type of error handler in VBA.

    Please Login or Register  to view this content.

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    plus
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  6. #6
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    Quote Originally Posted by JosephP View Post
    plus
    Please Login or Register  to view this content.


    Also
    Please Login or Register  to view this content.
    in Subs. But my question is - why don't Functions have an equivalent to this? I find it inconsistent.

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    Quote Originally Posted by mc84excel View Post
    Also
    Please Login or Register  to view this content.
    in Subs
    that is not valid syntax

  8. #8
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    Quote Originally Posted by JosephP View Post
    that is not valid syntax
    You're correct.

    (Puzzled. I was so certain that I used On Error Exit Sub in code in the past without any syntax errors. I must have been getting mixed up with something else).

  9. #9
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    Since On Error Exit Sub doesn't work either (my mistake everyone - it's been a long week) then there is no inconsistency and this thread is pointless. Marking "solved" now. (Pity we can't delete nonsense threads)

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    you may find it useful to have the vba language specification document http://download.microsoft.com/downlo...MS-VBAL%5D.pdf

    there's some weird stuff in there ;-)

  11. #11
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    Quote Originally Posted by JosephP View Post
    you may find it useful to have the vba language specification document http://download.microsoft.com/downlo...MS-VBAL%5D.pdf

    there's some weird stuff in there ;-)
    THANKS! Now this IS interesting. :D

    (With luck I might find something on my question for info on the lifetimes of changes to Application Properties - which other forum users appear to think I am wasting my time on!)

  12. #12
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    you won't-it's the specification for the vba language not a particular object model

  13. #13
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    Quote Originally Posted by JosephP View Post
    plus
    Please Login or Register  to view this content.
    Ah~~! I totally forgotten it and unable to retrieve from memories for which purpose it is used for

  14. #14
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    it both deactivates the current error handler and clears the current exception. I know of no good reason to ever use it :-)

  15. #15
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Quick beginner question-Why doesn't On Error Exit Function work?

    Thanks for the explanation and correction

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1