+ Reply to Thread
Results 1 to 5 of 5

Syntax Iferror Problem

  1. #1
    Registered User
    Join Date
    10-13-2008
    Location
    Australia
    MS-Off Ver
    2007
    Posts
    85

    Syntax Iferror Problem

    Hi,

    I'm trying to use the iferror function in VBA and the whole code is not executing, as the syntax error is being noticed first, and not allowing the whole code to execute. What I want to happen is if the vlookup returns an error, the cell value should be "*". The code is:

    Please Login or Register  to view this content.
    If I enter a correct entry into the input box, the vlookup works perfectly but if the vlookup returns an error, the syntax error is appearing first, and not allowing the iferror to work. How can I get around this and make sure the iferror returns * if the vlookup doesn't work?

    Cheers,
    Benno
    Last edited by benno87; 10-01-2009 at 12:09 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Syntax Iferror Problem

    What, exactly, are you trying to do?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    10-13-2008
    Location
    Australia
    MS-Off Ver
    2007
    Posts
    85

    Re: Syntax Iferror Problem

    Thanks for your quick response.

    I have attached a demo spreadsheet of what I'm trying to do. F8 should return the vlookup value. If you input A to F into the inputbox, it will return that value, but if you input G, it will error out in VB and not return "No Value" (I changed the error value in this example), as specified in the iferror formula, in VB.

    Hope this makes sense. Thanks for your help.

    Benno
    Attached Files Attached Files
    Last edited by benno87; 09-29-2009 at 12:31 AM. Reason: Uploaded spreadsheet

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Syntax Iferror Problem

    If you use .WorksheetFunction.VLookup an Error result will cause debug, if on the other hand you opt for Application.VLookup the Error will not cause a debug per se, eg:

    Please Login or Register  to view this content.
    (WorksheetFunctions are generally regarded as being slightly quicker to evaluate)

    Note: the above will only work in XL2007 given IFERROR function does not exist in prior versions... the below is an alternative approach

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-13-2008
    Location
    Australia
    MS-Off Ver
    2007
    Posts
    85

    Re: Syntax Iferror Problem

    That's great!! Thanks DonkeyOte, it works perfectly!

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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