+ Reply to Thread
Results 1 to 5 of 5

Resolved >>> Hide Blank rows within a range:

Hybrid View

  1. #1
    Registered User
    Join Date
    08-23-2007
    Posts
    58

    Resolved >>> Hide Blank rows within a range:

    Hello

    Can't seem to find a solution searching through various forums searches.

    I would like to hide all blank rows within a Named Range : Range1 (A1:E8)

    ie

    from this:

    ..A B C D E

    1 x x x x x
    2
    3 . x
    4
    5 x x x
    6
    7 . . x x
    8 x


    to look like this when rows are hidden:

    ..A B C D E

    1 x x x x x
    3 . x
    5 x x x
    7 . .x x
    8 x


    Thanks for any help

    ~Jeff

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    Sub HideRows()
    Dim Rng As Range
    Set Rng = Range("A1:E8")
    For i = Rng.Rows.Count To 1 Step -1 
    If WorksheetFunction.CountA(Rng.Rows(i)) = 0 Then
    Rng.Rows(i).EntireRow.Hidden = True
    End If
    Next i
    End Sub
    VBA Noob
    Last edited by VBA Noob; 10-23-2007 at 02:30 PM.
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    08-23-2007
    Posts
    58
    Thank you very much, VBA Noob!

    ..most helpful

    ~Jeff

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    No problem

    Glad it helped

    VBA Noob

  5. #5
    Registered User
    Join Date
    08-23-2007
    Posts
    58
    Hello, VBA Noob

    A follow up question if I may.

    ..Your code works perfectly with a blank worksheet, utilizing a few columns/rows as a test, However, when I bring it into my final database workbook, it still works, but is very slow.
    Even testing an 11 column by 20 row range takes about 8 seconds. (my worksheet length is around 700 rows.)


    I'm wondering if there is an alternative workaround to achieve the same result?


    I currently have this code (below) in my worksheet. When initiated by a button, it hides blank rows between 2 separate columns and takes about a second to execute.

    'Hide Blanks rows in Column "O & R"
    Private Sub Btn_HideRowBlank_R_Click()
      Intersect(Range("HideRow_O").SpecialCells(xlCellTypeBlanks).EntireRow, _
      Range("HideRow_R").SpecialCells(xlCellTypeBlanks).EntireRow) _
        .EntireRow.Hidden = True
    End Sub
    Not sure if this is helpful...

    any ideas?

    thanks again!

    jeff

+ 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