I'm very new in using VBA. The excel table has more than 500 rows. I would like to run vba code to remove row where column A is empty. I tried run this code.
It did remove the rows as I wanted. But, starting from column 31 and row 54, the field content goes to next field.How do I solve? Please help me. Thank you.
Code:
Sub DeleteAlternateRow()
Dim i As Long
Dim DelRange As Range
On Error GoTo Whoa
Application.ScreenUpdating = False
For i = 1 To 1500
If Application.WorksheetFunction.CountA(Range("A" & i & ":" & "DG" & i)) = 0 Then
If DelRange Is Nothing Then
Set DelRange = rows(i)
Else
Set DelRange = Union(DelRange, rows(i))
End If
End If
Next i
If Not DelRange Is Nothing Then DelRange.delete shift:=xlUp
LetsContinue:
Application.ScreenUpdating = True
Exit Sub
Whoa:
MsgBox Err.Description
Resume LetsContinue
End Sub
Comment