Ususally after doing a VLookup, people would like to delete the #N/A. In this case,I need to keep all the #N/A and delete the other rows not containing an "error". I have a code that I previously used to delete the #N/A and I am trying to rework it to do the complete opposite. Any help?
Previous code:
Previous code:
Code:
Sub OpenFileConductVlookup()
'
' OpenFileConductVlookup Macro
' Macro recorded 1/4/2013 by cac1057
'
'
Workbooks.Open Filename:= _
"S:\Small Business\Previous Hold Transfer Report.XLS"
Range("A1:I1").Select
Selection.Interior.ColorIndex = 3
Windows("Daily Hold Transfer Report.xls").Activate
Windows("Previous Hold Transfer Report.XLS").Activate
Columns("C:C").Select
Dim LastRow As Long
LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row
Selection.Insert Shift:=xlToRight
Range("C2:C" & LastRow).FormulaR1C1 = _
"=VLOOKUP(RC[-1],'[Daily Hold Transfer Report.xls]HoldTransfer Over & Under 25 Ja'!C2,1,FALSE)"
Dim r As Long
Dim iCol As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
.DisplayAlerts = False
For iCol = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
For r = Cells(Rows.Count, iCol).End(xlUp).Row To 1 Step -1
If Application.WorksheetFunction.IsNA(Cells(r, iCol)) Then Rows(r).Delete
Next r
Next iCol
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
.DisplayAlerts = True
End With
Windows("Daily Hold Transfer Report.xls").Activate
End Sub