Results 1 to 8 of 8

best practice on error handling formulas in VBA

Threaded View

  1. #1
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    best practice on error handling formulas in VBA

    It is literally just a best practice question really.
    Is it better practice/more efficient when filling a formula (normally in my case a lookup) down a column in VBA to put any error handing in the formula something like
    Dim LastRow As Long
        With Sheet1    
            LastRow = .UsedRange.Rows.Count
            .Range(.Cells(2, 16), .Cells(LastRow, 16)).FormulaR1C1 = _
    "=if(iserror(vlookup(…)),”not found”,vlookup(…))"
    which is what I normally do, or is it better to write any error handling as part of the VBA routine i.e. an "On Error" piece of coding?

    Or is it personal preference either way?

    Any insight will be gratefully received (and yes in an ideal world I would love all the info at work not to trigger an error in the first place but sometimes it should)
    Last edited by WasWodge; 09-29-2011 at 05:36 PM.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

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