Notice: WC_Cart::get_cart_url is deprecated since version 2.5! Use wc_get_cart_url instead. in /home/swatipaliwal/public_html/excelcrazy.com/wp-includes/functions.php on line 3839
Excel Crazy

How to Delete Blank Rows in Excel Using VBA

 

If there are hundreds of blank rows in the whole worksheet and you want to delete them all in one click or macro. This tutorial will help you to delete blank rows in entire worksheet.

Click Developer Tab > Visual Basic, a new Microsoft Visual Basic for Applications window will open.

Click Insert > Module, and copy paste the below code into the module.

Sub DeleteRows()

Dim ws As Worksheet
Dim LastRow As Long

Set ws = ActiveSheet

LastRow = ws.Range(“A” & ws.Rows.Count).End(xlUp).Row

With ws.Range(“A2:A” & LastRow)
    If  WorksheetFunction.CountBlank(.Cells) > 0 Then
        .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End If
End With

End Sub

June 11, 2015

0 responses on "How to Delete Blank Rows in Excel Using VBA"

Leave a Message

Your email address will not be published. Required fields are marked *

top
 

© LOKESH PALIWAL 1987 - 2017

Reporting Solutions | Data Consulting | Analytics Training