Link to home
Start Free TrialLog in
Avatar of intangiblemedia
intangiblemediaFlag for Afghanistan

asked on

Remove Blank Rows in Excel / CSV file

Hi,

I have a few lists that I need to standardise. They are CSV files and have blank rows in them.

How can I remove any blank rows programmatically in Excel?

Thanks,

Ben
Avatar of gtgloner
gtgloner
Flag of Canada image

Here is some example code of how it might be done. This assumes that your data is in columns A and B:
Sub Macro1()

    Columns("A:B").Select
    Selection.AutoFilter
    Selection.AutoFilter Field:=1, Criteria1:="<>"
    Range("A1:B65536").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of gtgloner
gtgloner
Flag of Canada 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
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
sorry, my macro is for deleting cells not rows....sorry......disregard it
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
Warning on gtgloner's solution. Just as mine, it assumes that if the cell in column A is empty, then the whole row is empty.

Let us know if that's not the case and we can adjust the code to fit your needs,

Thomas
SOLUTION
Avatar of Dave
Dave
Flag of Australia 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
Avatar of intangiblemedia

ASKER

thanks all