how delete empty rows?

khardu

Board Regular
Joined
Jan 18, 2012
Messages
68
Hello Excel Users!!

Is there a way to delete empty rows in the data?

a few months ago, I posted the same thread here, and, in reply, the VBA codes suggested to me were:


Sub DeleteEmptyLines2()

Dim r As Range
Dim numCells As Long

Application.ScreenUpdating = False
Application.EnableEvents = False

numCells = ActiveSheet.UsedRange.Rows(1).Cells.Count

For Each r In ActiveSheet.UsedRange.Rows
If WorksheetFunction.CountBlank(r) = numCells Then
r.EntireRow.Delete
End If
Next

Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub





OR



Sub DeleteEmptyRows()

Dim r As Range

Application.ScreenUpdating = False
Application.EnableEvents = False

For Each r In ActiveSheet.UsedRange.Rows
If WorksheetFunction.CountA(r) = 0 Then
r.EntireRow.Delete
End If
Next

Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub







They did the job well, but now they are not working. I tried it them excel 2007 on a trial balance which had alternative rows empty. Now I am trying both codes in 2007 and 2013, they aren't eliminating the empty rows from the data.

I have a different trial balance which I have exported from a software, it has alternative rows with no data in them. I want to delete them. Could you please help me out.


Thanking you.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
it worked! I was using it in incorrectly. I forgot to run the macro. I was thinking that it will start deleting rows as soon as I copy and past the code in VBA editor. Thanks to Excel Forum, it's very helpful.
 
Upvote 0

Forum statistics

Threads
1,215,547
Messages
6,125,461
Members
449,228
Latest member
moaz_cma

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