Hi,
I receive the following error while trying to delete some cells:
Run-time error '1004': Cannot use that command on overlapping selections
This is my code:
Here LastRow is the last row with data and the file is filtered, that is why I wanted to select all cells from 2 to the last row (2 to exclude the headers) and select only the visible cells that I need to keep on the report and then delete the rest.
It gives me the error on the "Selection.EntireRow.Delete" part.
Any thoughts on why this may be cause ot how to fix this?
Thanks!
Sebastian
I receive the following error while trying to delete some cells:
Run-time error '1004': Cannot use that command on overlapping selections
This is my code:
Code:
Rows("2:" & LastRow).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.EntireRow.Delete
Here LastRow is the last row with data and the file is filtered, that is why I wanted to select all cells from 2 to the last row (2 to exclude the headers) and select only the visible cells that I need to keep on the report and then delete the rest.
It gives me the error on the "Selection.EntireRow.Delete" part.
Any thoughts on why this may be cause ot how to fix this?
Thanks!
Sebastian