Microsoft Office Tutorials and References
In Depth Information
Deleting the Empty Rows in a Range
Exl
Figure 27 – Worksheet After Running Macro
View the Appendix to learn how to store this procedure
in a Standard module.
Option Explicit¶
' * * * * *¶
Sub DeleteEmptyRows()¶
'Variable declaration¶
Dim Rng As Range¶
Dim Rw As Range¶
'Change the following variables¶
'Hard coded range¶
Set Rng = Range("A2:E20")¶
'User inputs range by selecting it.¶
'Set Rng = ActiveWindow.RangeSelection¶
'Turn off screen updating¶
Application.ScreenUpdating = False¶
'Loop through each row¶
For Each Rw In Rng.Rows¶
'Is this row of data empty? (Use COUNTA() to check this)¶
If Application.CountA(Rw) = 0 Then¶
'Rw is empty¶
Rw.Delete Shift:=xlShiftUp¶
End If¶
Search JabSto ::




Custom Search