Delete row if blank cell on very large data sets (Macro just deletes all data) code attached

Slomaro2000

Board Regular
Joined
Jun 4, 2008
Messages
107
Hello all,
I have very large datasets 100k or more. I need the row deleted if the cell a cell in say column A is blank.

These codes work on data sets that are not huge.
Code:
Sub Delete1()
Application.ScreenUpdating = False
Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Application.ScreenUpdating = True
End Sub

Same happens when I just filter by blank and try to delete the rows. Crashes and deletes everything.



Could run this but this takes around 10min for 100k rows. Anything faster? I have looked and looked with no luck.
Code:
Sub one()
    Dim j As Long
    For j = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
    If Cells(j, "A") = "" Then Cells(j, "A").EntireRow.Delete xlUp
    Next j
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Let's say your data set has a headrow in row 2

Code:
Rows("2:2").AutoFilter  Field:=1, Criteria1:="="

Then just select and delete rows...

-------------------------------------

Alternately, turn off Screen Updating for a faster run time (Application.ScreenUpdating = False)
 
Upvote 0

Forum statistics

Threads
1,216,151
Messages
6,129,162
Members
449,489
Latest member
spvclub

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