How to Delete Blank Rows in Excel Using VBA

Share Now

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
    End If
End With

End Sub

Share Now
November 15, 2019

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 *

    Tableau Training in Delhi

    EC Analytics will help your business make better decisions by providing expert-level business intelligence (BI) services. Forecasting, strategy, optimization, performance analysis, trend analysis, customer analysis, budget planning, financial reporting and more. EC Analytics also offers Advanced Data Analytics training in corporate and retail.


    0124- 4601426

    Featured Testimonial

    "I highly...Read more

    Neha Dhawan (Senior Manager)

    Michelin India Private Limited

    EC Analytics Consulting @ 2019 ALL RIGHTS RESERVED