Tuesday 21 May 2013

Macro to remove blank rows from Excel sheet

Example - Below code will remove all blank rows from the excel sheet


 Range("A1:A100").Select


For i =0  To  Selection.Rows.Count

If  WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then

Selection.Rows(i).EntireRow.Delete        

End If

Next i


In above code we are deleting all empty rows between A1 to A100.
CountA function is returns the number of non-empty cells. When it returns 0 , That means entire row is blank.


No comments:

Post a Comment

Popular Posts

Search This Blog