+ Reply to Thread
Results 1 to 3 of 3

hiding a few rows with a macro takes forever

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-13-2006
    Location
    Texas
    Posts
    161

    hiding a few rows with a macro takes forever

    Folks,

    My code snippet is attached below. Notes follow.

    I am working on a range of less than 50 rows on a single worksheet. I have screenupdating turned off. Even so, this macro seems to take forever (in computer time). This is the only thing the macro is doing, so I think I may be using a poor choice of syntax. Any help would be appreciated. Thanks in advance.

    Conor.
     For Each rw In Worksheets("User Dialog").Range("OrderQuantities").Rows
        
        If rw.Cells(1, 1) = "" Then
            rw.Hidden = True
        End If
    Next
    FYI - OrderQuantities is a named range one column x 45 rows
    Last edited by VBA Noob; 07-09-2007 at 03:28 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Conor,

    The reason it takes so long is you are hiding the cells. Each time a cell is hidden, the data in other columns on that row has to be shifted. It would much faster to hide the column of your named range.

    Sincerely,
    Leith Ross

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Use SpecialCells

    On Error Resume Next 'prevent error if no cells are blank
     Sheet1.Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True
    On Error GoTo 0
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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