How to delete duplicate empty rows in excel?

bob122

New Member
Joined
May 10, 2018
Messages
17
Okay so everybody knows how to delete mass empty rows via the go to special blank option. But how can I delete only the duplicate empty rows? EG:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]7[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]8[/TD]
[/TR]
</tbody>[/TABLE]

so above turns into:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]7[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]8

[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Assuming blanks in Column A equate to blanks in other columns, here is a macro that should do what you want...
Code:
[table="width: 500"]
[tr]
	[td]Sub LeaveOneBlankRow()
  Dim Ar As Range
  With Range("A1", Cells(Rows.Count, "A").End(xlUp))
    For Each Ar In .SpecialCells(xlBlanks).Areas
      If Ar.Rows.Count > 1 Then Ar.Offset(1).Resize(Ar.Rows.Count - 1).EntireRow.Delete
    Next
  End With
End Sub[/td]
[/tr]
[/table]

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (LeaveOneBlankRow) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0
[Table="width:, class:grid"][tr][td="bgcolor:#C0C0C0"][/td][td="bgcolor:#C0C0C0"]
B​
[/td][td="bgcolor:#C0C0C0"]
C​
[/td][td="bgcolor:#C0C0C0"]
D​
[/td][td="bgcolor:#C0C0C0"]
E​
[/td][/tr][tr][td="bgcolor:#C0C0C0"]
1​
[/td][td="bgcolor:#F3F3F3"]
Hdr1
[/td][td="bgcolor:#F3F3F3"]
Hdr2
[/td][td="bgcolor:#F3F3F3"]
Formula
[/td][td="bgcolor:#F3F3F3"]
[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
2​
[/td][td]
7​
[/td][td]
8​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td]D2: =(COUNT(B2:C2) = 0) * SUM(D1, 1)[/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
3​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
1​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
4​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
2​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
5​
[/td][td]
4​
[/td][td]
7​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
6​
[/td][td]
1​
[/td][td]
9​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
7​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
1​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
8​
[/td][td]
4​
[/td][td]
8​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
9​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
1​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
10​
[/td][td]
7​
[/td][td]
5​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
11​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
1​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
12​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
2​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
13​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
3​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
14​
[/td][td]
7​
[/td][td]
7​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
15​
[/td][td]
6​
[/td][td]
8​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
16​
[/td][td]
8​
[/td][td]
8​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
17​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
1​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
18​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
2​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
19​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
3​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
20​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
4​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
21​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
5​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
22​
[/td][td][/td][td][/td][td="bgcolor:#E5E5E5"]
6​
[/td][td][/td][/tr]
[tr][td="bgcolor:#C0C0C0"]
23​
[/td][td]
7​
[/td][td]
8​
[/td][td="bgcolor:#E5E5E5"]
0​
[/td][td][/td][/tr]
[/table]


Filter for col D > 1, delete those rows, unfilter, delete col D.
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top