Hi, I am currently using a VBA to run a vlookup and than delete any row that returns "N/A". I need to move these rows the a sheet called "Removed" so I can reference them in the future if there are any problems. I will need the newly moved rows the be added to the bottom of the list. My current VBA Code is:
Sub ChequeRemove()
Dim wb As Workbook, oWS As Worksheet, nWS As Worksheet
Dim i As Long, LastRow As Long, LastCol As Long, nLastRow As Long
Set wb = ActiveWorkbook
Set oWS = wb.Sheets("Outstanding ST Loans")
Set nWS = wb.Sheets("New")
nLastRow = nWS.Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Row
LastRow = oWS.Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Row
LastCol = oWS.Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Column
oWS.Range(Cells(1, LastCol + 1), Cells(LastRow, LastCol + 1)).FormulaR1C1 = "=VLOOKUP(RC[" & 11 - (LastCol + 1) & "],'" & nWS.Name & "'!R1C4:R" & nLastRow & "C4,1,FALSE)"
For i = LastRow To 1 Step -1
If oWS.Cells(i, (LastCol + 1)).Text = "#N/A" Then Rows(i).EntireRow.Delete
Next i
End Sub
Thank you for any help you can give.
Sub ChequeRemove()
Dim wb As Workbook, oWS As Worksheet, nWS As Worksheet
Dim i As Long, LastRow As Long, LastCol As Long, nLastRow As Long
Set wb = ActiveWorkbook
Set oWS = wb.Sheets("Outstanding ST Loans")
Set nWS = wb.Sheets("New")
nLastRow = nWS.Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Row
LastRow = oWS.Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Row
LastCol = oWS.Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Column
oWS.Range(Cells(1, LastCol + 1), Cells(LastRow, LastCol + 1)).FormulaR1C1 = "=VLOOKUP(RC[" & 11 - (LastCol + 1) & "],'" & nWS.Name & "'!R1C4:R" & nLastRow & "C4,1,FALSE)"
For i = LastRow To 1 Step -1
If oWS.Cells(i, (LastCol + 1)).Text = "#N/A" Then Rows(i).EntireRow.Delete
Next i
End Sub
Thank you for any help you can give.