+ Reply to Thread
Results 1 to 2 of 2

Adapt VBA to skip a row and avoid #N/A

  1. #1
    Forum Contributor
    Join Date
    05-29-2009
    Location
    sheffield
    MS-Off Ver
    Excel 2013
    Posts
    210

    Adapt VBA to skip a row and avoid #N/A

    On the attached, I have the following VBA that does an XLOOKUP and returns a corresponding postcode based on an address code in column E

    ws2.Range("L2:L" & Range("L999").End(xlDown).Row) = Application.WorksheetFunction.XLookup(Range("E2:E999"), Sheets("ADDRESSES").Range("A2:A102"), Sheets("ADDRESSES").Range("E2:E102"))

    This is working other than I am getting a #N/A in column L every other row because of the way my spreadsheet populates. I need to adapt the VBA so that it ignores every other row and avoids the #N/A error. I'm not sure how to adapt my range to do this.

    Any help is greatly appreciated.
    Attached Files Attached Files
    Last edited by johnmitch38; 03-30-2023 at 10:44 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Adapt VBA to skip a row and avoid #N/A

    use the Fourth argument of the function, which is the value to return if not found.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

+ 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. how to skip user form clear to skip particular text box
    By narsing18 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2017, 08:44 AM
  2. Adapt code
    By walber in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 03-13-2017, 04:46 AM
  3. [SOLVED] Adapt Code
    By PaulCooke in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-15-2015, 12:05 PM
  4. # of blank labels to skip
    By jdlc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2014, 03:36 PM
  5. Adapt CONCATENATE to skip rows
    By Celex005 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-29-2012, 08:21 PM
  6. Formula for avg skip, max skip, longest out
    By Jordans121 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-12-2010, 04:56 PM
  7. Please help me to adapt this code.
    By Rob Hargreaves in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2005, 05: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