+ Reply to Thread
Results 1 to 4 of 4

Using IFERROR in VBA

Hybrid View

  1. #1
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,983

    Re: Using IFERROR in VBA

    Try this. In VBA when you use WorksheetFunction, it is not simply a copy of the actual worksheet function. It is a VBA Function with parameters, and the parameters must be VBA expressions. In VBA, using F1 unadorned like that means it's an undeclared variable. It will cause a compile error if you use Option Explicit, and otherwise will just be a Variant variable that hasn't been assigned a value. You have to use an expression that results in a Range.

    Dim lngLastRow As Long
    
    lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
        Range("h1:h" & lngLastRow).Formula = Application.WorksheetFunction.IfError(Mid(Range("F1"), (Find("-", Range("F1")) + 1), 2), Range("F1"))
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  2. #2
    Registered User
    Join Date
    10-31-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Using IFERROR in VBA

    Thanks 6 string. It is now objecting the "find" function. Do I need to have another reference to the worksheet function before using "find"

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. xlfn.IFERROR or IFERROR don't work in Excel 98-2003
    By dj_danu01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2013, 02:53 AM
  2. [SOLVED] no IFERROR
    By DBenson1968 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-26-2013, 03:52 PM
  3. [SOLVED] Sum+IFERROR Help
    By chriswiec in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-27-2013, 09:43 AM
  4. [SOLVED] Iferror
    By Notters in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-04-2013, 12:34 PM
  5. If? Iferror?
    By amthyst826 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-22-2010, 08:06 PM

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