Link to home
Start Free TrialLog in
Avatar of tahirih
tahirih

asked on

Excel - delete rows - if condition

Hi,

Is there a way to delete rows from a worksheet if the cell in column A is blank? This would be performed on all sheets in the workbook, so I am not sure if there is a macro mechanism for this.

Thank you
Avatar of Christian de Bellefeuille
Christian de Bellefeuille
Flag of Canada image

I don't know any function that would perform that in Excel.

I can write a macro for you if you want
Avatar of tahirih
tahirih

ASKER

Only if you have the time - this would be wonderful.

Again, I would want to remove rows from all sheets where the cell in column A for that row is blank.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of byundt
byundt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
well, byundt just shifted me... his solution work just fine
The manual equivalent to the macro is:
1) Select column A
2) F5 and click the Special Cells... button at the bottom of the resulting dialog
3) Choose the option for Blanks
4) Use the Home...Delete...Delete Sheet Rows menu item (in Excel 2010)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You might have to edit the code depending on the column that you are looking for the blanks in.
Avatar of tahirih

ASKER

Thank you everyone! I will be revisiting this project in a bit - so your patience is appreciated during the interim.

tahirih,

Brad's suggestion should work quite well.  The only caveat is that if you have >16k rows in your source data, then there is a possibility that SpecialCells will fail.  (SpecialCells fails if it returns >8192 distinct areas.)

The usual workaround for that is to sort the data first.

Patrick
Avatar of tahirih

ASKER

Thank you everyone.