PDA

View Full Version : Sleeper: Invalid references table and copy the valids to another table



jmaocubo
04-06-2010, 09:13 AM
Hello everyone


I have a table that has a listing that will have invalid references (deliberate).

It is possible to get this table and copy to another, but only the valid.

The size of the table is random....


Source table:

5 |#REF!
2 |1
2 |#REF!
5 |#REF!
5 |30
5 |40
7 |#REF!
… |…



Destination table:

2 |1
5 |30
5 | 40
… …


Imagining that the source table starts in A1 and the target table in N53

I thank you


Regards,
Miguel

Bob Phillips
04-06-2010, 09:23 AM
Air-coded



Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim LastRow As Long
Dim NextRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To LastRow
If IsError(.Cells(i, TEST_COLUMN).Offset(0, 1).Value2) Then
.NextRow = NextRow + 1
.Rows(i).Copy Worksheets("Sheet2").Cells(NextRow, "A")
End If
Next i
End With
End Sub