+ Reply to Thread
Results 1 to 6 of 6

Use VBA to hide rows containing no text.

Hybrid View

  1. #1
    Registered User
    Join Date
    12-09-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Question Use VBA to hide rows containing no text.

    I have a sheet that pulls comments based on data entered from another sheet. The problem is that there are lots of empty rows not containg text on my comments sheet because the data entered on the other sheet doesn't pull a comment based on the data entered.
    I need to write a macro that will hide all the empty rows that don't contain any text so I can print all the comments.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Use VBA to hide rows containing no text.

    You should be able to select a column, press F5, Special,Blanks, then go to Format at the top menu, rows, hide.

  3. #3
    Registered User
    Join Date
    12-09-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Use VBA to hide rows containing no text.

    I didn't know that but it doesn't do what I was looking for. I need my empty rows, not colums, that don't contain any text to auto hide every time the if,then functions I have written in those cells don't pull a text comment from another sheet.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Use VBA to hide rows containing no text.

    Do a forum search, Hide Blank Rows

  5. #5
    Registered User
    Join Date
    12-09-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Use VBA to hide rows containing no text.

    I found a code that works however I have some cells that contain "#N/A" that I still need to hide. How can I edit the following code to also hide cells that contain this?


    Private Sub Worksheet_Activate()
    Dim rng As Range, cell As Range
    Static bCount As Byte
    If bCount Then Exit Sub
    Application.ScreenUpdating = False
    Set rng = Application.Intersect(ActiveSheet.UsedRange, Range("A7:A90"))
    For Each cell In rng.Columns(1).Cells
    If Application.CountBlank(Intersect(cell.EntireRow, rng)) = rng.Columns.Count Then cell.EntireRow.Hidden = True
    Next
    Application.ScreenUpdating = True
    bCount = bCount + 1
    End Sub

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Use VBA to hide rows containing no text.

    goPatsgoSox, please note:

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here


    Please edit you prior post in accordance with the above

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1