1

I'm trying to find a way to find rows with #na so that I can copy the row and past it in another tab so that the error can be analysed.

So far I have the following, but I have some problems

Dim iCntr As Long
Dim lastColumn As Long
For iCntr = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
    For lastColumn = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column To 1 Step -1
        If Cells(iCntr, lastColumn).Text = "#N/A" Then
            MsgBox "row" & iCntr
        End If
    Next
Next

First of all, the code doesn't seem to find cells with #N/A errors. I'm not sure why.

Also, I have 60K rows and 50 columns and trying to run the code above is taking very long. I would like for the code jump the next line as soon as a #N/A is found as there is no need to check the rest of the columns

Any ideas on how to resolve the previous points?

At the moment I'm just showing a message box, but I the intention is to copy all the row once the #N/A is found and copy it to another page one row after the other.

Selrac
  • 2,203
  • 9
  • 41
  • 84
  • 2
    If you want to select error cells, I believe you could just use `range("A:A").SpecialCells(xlCellTypeFormulas,xlErrors)` – BruceWayne Feb 23 '17 at 15:29

1 Answers1

3

You are trying to find the string "#N/A" - that will not work. Excel has the function IsNA(), and in VBA you can use Application.WorksheetFunction.IsNA(rngToCheck.Value)

Hope this helps.

Mihai Ovidiu Drăgoi
  • 1,307
  • 1
  • 10
  • 16