I don't know whether this is the right forum or not. Here, I am sharing with you how to delete blank rows in the same worksheet using a macro. Please refer to the attached file where step-by-step guidelines are available along with the clarification behind the commands. If you need to handle large data in Excel and often require arranging the data correctly, then this macro may be very useful to you.

Regards

From India, Kolkata
Attached Files (Download Requires Membership)
File Type: pdf Delete BlankRows.pdf (317.5 KB, 284 views)

Acknowledge(0)
Amend(0)

Guide to Deleting Blank Rows in Excel Using a Macro

To delete blank rows in the same worksheet using a macro in Excel, follow these steps:

1. Press `Alt + F11` to open the Visual Basic for Applications (VBA) editor.
2. Click on `Insert` in the menu bar and select `Module` to insert a new module.
3. Copy and paste the following VBA code into the module:

```vba
Sub DeleteBlankRows()
Dim rng As Range, cell As Range
Dim delRange As Range
Dim ws As Worksheet

Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your sheet name

On Error Resume Next
Set rng = ws.UsedRange
On Error GoTo 0

If Not rng Is Nothing Then
For Each cell In rng
If Application.WorksheetFunction.CountA(cell.EntireRo w) = 0 Then
If delRange Is Nothing Then
Set delRange = cell
Else
Set delRange = Union(delRange, cell)
End If
End If
Next cell
End If

If Not delRange Is Nothing Then
delRange.EntireRow.Delete
End If
End Sub
```

4. Modify the code to specify the correct sheet name if needed (change `"Sheet1"` to your actual sheet name).
5. Press `F5` to run the macro. This will delete all blank rows in the specified worksheet.

By following these steps, you can efficiently delete blank rows in Excel using a macro, streamlining your data management process.

From India, Gurugram
Acknowledge(0)
Amend(0)

CiteHR is an AI-augmented HR knowledge and collaboration platform, enabling HR professionals to solve real-world challenges, validate decisions, and stay ahead through collective intelligence and machine-enhanced guidance. Join Our Platform.







Contact Us Privacy Policy Disclaimer Terms Of Service

All rights reserved @ 2025 CiteHR ®

All Copyright And Trademarks in Posts Held By Respective Owners.