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:-


    Code
    Sub delete()
    Selection.CurrentRegion.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Selection.EntireRow.delete
    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.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!