L
Len
Hi,
After data exported to excel file which contain about 20,000 rows and
20 columns, certain cells contain no data or value but do not belong
to blank cells ( ie after using GoTo Special/Search for blanks cell )
I tried to delete entire rows that contain no data from the above file
by using the codes in Excel 2007 below ( thanks to VBA Express ) and
the result has no response
Sub DeleteBlankRows()
Dim Rw As Long, RwCnt As Long, Rng As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
On Error GoTo Exits:
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = Range(Rows(1),
Rows(ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row()))
End If
RwCnt = 0
For Rw = Rng.Rows.Count To 1 Step -1
If
Application.WorksheetFunction.CountA(Rng.Rows(Rw).EntireRow) = 0 Then
Rng.Rows(Rw).EntireRow.Delete
RwCnt = RwCnt + 1
End If
Next Rw
Exits:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Any help will be much appreciated and thanks in advance as I'm VBA
beginner
Regards
Len
After data exported to excel file which contain about 20,000 rows and
20 columns, certain cells contain no data or value but do not belong
to blank cells ( ie after using GoTo Special/Search for blanks cell )
I tried to delete entire rows that contain no data from the above file
by using the codes in Excel 2007 below ( thanks to VBA Express ) and
the result has no response
Sub DeleteBlankRows()
Dim Rw As Long, RwCnt As Long, Rng As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
On Error GoTo Exits:
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = Range(Rows(1),
Rows(ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row()))
End If
RwCnt = 0
For Rw = Rng.Rows.Count To 1 Step -1
If
Application.WorksheetFunction.CountA(Rng.Rows(Rw).EntireRow) = 0 Then
Rng.Rows(Rw).EntireRow.Delete
RwCnt = RwCnt + 1
End If
Next Rw
Exits:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Any help will be much appreciated and thanks in advance as I'm VBA
beginner
Regards
Len