简体   繁体   中英

Excel VBA - Search certain column for a #N/A, copy entire row to new sheet and delete row

This is what I have already. It searches column B in sheet 1 for #N/A and deletes the row.

Sub DeleteErrorRows()
    On Error Resume Next    
    Range("B:B").SpecialCells(xlCellTypeConstants, 16).EntireRow.Delete
    On Error GoTo 0     
End Sub

What I would like is for it to copy that row onto sheet 2 and then delete? So I can have a record of what was deleted.

Any help would be much appreciated. Thanks!

Consider:

Sub DeleteErrorRows()
    Dim r As Range
    Set r = Range("B:B").SpecialCells(xlCellTypeConstants, 16).EntireRow
    r.Copy Sheets("Sheet2").Range("A1")
    r.Delete
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM