Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to use the following macro to get rid of some blank rows:
Range("A1").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.DeleteThe problem is that I must do this on a column of data that was pasted from another worksheet using Edit, Paste Special, Values only. Although the blank cells do not have any data or formulas in them Excel is not recognizing them as blank and the macro cannot delete the associated rows.
I tested this using the Edit, Goto, Special command choosing the Blanks selection. That action does not select the empty cells in the column, just those around the pasted cells.
Can anyone help me with this bugger so that the macro will work the way it should? Thanks.

Hi Walt
I think your problem is in the line:
Range("A1").SelectYou should redefine the area that has been pasted into, and THEN perform the rest of your macro. For example:
If you know that the pasted values are always in the first column, then use:
Range("A:A").Select
or
Columns(1).Selectof course, as I always say, I LOVE one-liners, so you could always forget the "select" business and try:
Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
as one line (which just doesn't fit on this page).
DON'T FORGET: When you define the range within which to expose the blank cells, if the ranges overlap you will get an error (which is why the 'select a whole column' method usually gets my vote - Nb. It will only look within a used range, so its not going to go checking 65535 rows of data every time, so no real speed issues)
Hope that answers your problem.
Tom

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |