Error on deleting blank rows

  • Hi everyone,

    I wrote the following code. I am running a query through power query. Selecting the data. Copying it as values. And then Selecting the blank cells and trying to delete the the entire row.

    Bit I am getting the error on the last line of code. "Selection.EntireRow.delete"

    Error - Delete method of Range has failed.

    Following is the code:-

    1. Sub delete()
    2. Selection.CurrentRegion.Select
    3. Selection.Copy
    4. Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    5. :=False, Transpose:=False
    6. Application.CutCopyMode = False
    7. Selection.SpecialCells(xlCellTypeBlanks).Select
    8. Selection.EntireRow.delete
    9. End Sub

    Please help.

    Edited once, last by royUK: Add code tags, please do this yourself in future ().

  • Check the changes below. I'm sure it will work. Not pretty... Not elegant... Should be functional.