Find XLookup #N/A Errors and Copy Row and PasteValues into a new list on new worksheet

kyddrivers

Board Regular
Joined
Mar 22, 2013
Messages
64
Office Version
  1. 365
Platform
  1. Windows
I am tasked with finding an easy way to search a list, look for the #N/A returns from an XLookup, and copy and paste values the row containing the error into a new worksheet so all of the errors are in 1 list that can be audited.

The list looks like this:

Audits.xlsx
ABCDE
1Last Name, First NameEmailSatusEnd/Inactive Date
2Smith, Jackjsmith@xlookup.comActive1/0/1900Blank
3Dough, Jonjdough@xlookup.com#N/A
Lookup
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D:ECell Value>22510textNO


In this example, I need the code to look for the #N/A return in row 3, copy it and paste it into a new tab. Then return to the list and keep going until all of the #N/As are compiled in a new list.

I was thinking of using SpecialCells(xlFormulas, xlErrors) and sketched out some non-functional code like this.

VBA Code:
Sub Lookup()

Dim LastRow As Long
Dim LastRow2 As Long
Dim i As Long

Worksheets("Lookup").Activate
LastRow = Cells(Rows.Count, 5).End(xlUp).Row

For i = 2 To LastRow
Worksheets("Lookup").Activate

If Range("E2:E" & LastRow).SpecialCells(xlFormulas, xlErrors) Then

Range("E2:E" & LastRow).SpecialCells(xlFormulas, xlErrors).Copy

'Paste into this sheet
   Worksheets("Audit Looup").Activate
   LastRow2 = Cells(Rows.Count, 1).End(xlUp).Row + 1
   Worksheet.Range("A" & LastRow2).PasteSpecial

End If
Next i

End Sub

Am I on the right path? Is there a better way to do this? Is this task even feasible?

Thanks in advance!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try this:

Note: Check the name of your sheets.
VBA Code:
Sub copyerrors()
  Dim sh1 As Worksheet, sh2 As Worksheet
  Set sh1 = Sheets("Lookup")
  Set sh2 = Sheets("Audit Looup")
  On Error Resume Next
  Intersect(sh1.Range("E:E").SpecialCells(xlConstants, xlErrors), sh1.Range("E:E")).EntireRow.Copy
  sh2.Range("A" & sh2.Range("A" & Rows.Count).End(3).Row + 1).PasteSpecial xlPasteValues
End Sub



--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------​
 
Upvote 0
Solution

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top