Cutting Row with Data and moving to different sheet VBA

Posted by user3709645 on Stack Overflow See other posts from Stack Overflow or by user3709645
Published on 2014-06-10T02:19:39Z Indexed on 2014/06/10 3:25 UTC
Read the original article Hit count: 107

Filed under:
|
|

I'm trying to cut a row that has the specified cell blank and then paste it into another sheet in the same workbook. My coding works fine to delete the row but everything I've tried to cut and paste keeps giving me errors. Here's the working code that deletes the rows:

Sub Remove()

    'Remove No Denovo &/or No Peak Seq
    Dim n As Long
    Dim nLastRow As Long
    Dim nFirstRow As Long
    Dim lastRow As Integer

    ActiveSheet.UsedRange

    Set r = ActiveSheet.UsedRange
    nLastRow = r.rows.Count + r.Row - 1
    nFirstRow = r.Row

    For n = nLastRow To nFirstRow Step -1
        If Cells(n, "G") = "" Then Cells(n, "G").EntireRow.Delete
    Next n

End Sub

Thanks for any help!

© Stack Overflow or respective owner

Related posts about excel

Related posts about vba