When I need to hide blank lines in excel I use the following. First I select a range then run the following macro. This will hide all lines in the selected range which have no numerical values. This is pretty simplistic and has virtually no error checking, but it does what I need and I thought it might be helpful for others.
Public Sub HideBlankLines()
Dim rngLine As Range
Dim rngCell As Range
Dim bolNonBlankFound As Boolean
Application.ScreenUpdating = False
For Each rngLine In Application.Selection.Rows
bolNonBlankFound = False
For Each rngCell In rngLine.Columns
If Len(rngCell.Text) > 0 Then bolNonBlankFound = True: Exit For
Next rngCell
If Not bolNonBlankFound Then rngLine.EntireRow.Hidden = True
Next rngLine
Application.ScreenUpdating = True
End Sub
I hate doing things I can make my computer do for me. My adventures in customizing and automating computers. Primarily with AutoCAD and Microsoft Office.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment