Need to edge out the competition for your dream job? Train for certifications today.
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
i = 1
j = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
Do While i < j
If ActiveSheet.Range("A" & i).Value = "" Then
i = i - 1
j = j - 1
i = i + 1
Open in new window
'based on code from dlmille, Experts Exchange Q_27636554
Dim rng As Range
Dim r As Range
Dim chkRow As String
Dim rng2 As Range
Dim r2 As Range
Dim rDelete As Range
Dim lngLR, lngLC As Long
lngLR = Cells.SpecialCells(xlLastCell).Row
lngLC = Cells.SpecialCells(xlLastCell).Column
Set rng = Range("A2", Cells.SpecialCells(xlLastCell))
For Each r In rng
Set rng2 = Range(Cells(r.Row, 1), Cells(r.Row, lngLC))
For Each r2 In rng2
chkRow = chkRow & Trim(r2.Value)
If chkRow = vbNullString Then
If rDelete Is Nothing Then
Set rDelete = r
Set rDelete = Union(r, rDelete)
chkRow = vbNullString
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete
Dim row As Range
Dim sheet As Worksheet
Set sheet = ActiveSheet
For i = sheet.UsedRange.Rows.Count To 1 Step -1
Set row = sheet.UsedRange.Rows(i)
If WorksheetFunction.CountA(row) = 0 Then
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment