Closed Thread
Results 1 to 3 of 3

hide row based on cell value in multiple sheets

  1. #1
    Registered User
    Join Date
    09-18-2009
    Location
    england
    MS-Off Ver
    Excel 2003
    Posts
    24

    hide row based on cell value in multiple sheets

    Hi all,

    I have this macro that hides rows when the value is “0”.


    At the moment it’s not running very smoothly and updating quickly, i.e the Application.Sreenupdating isn’t working correctly.


    I would also like to add run this in multiple sheets at the same time. Is this also possible?


    Sub HideRows()

    Dim cell As Range

    Application.ScreenUpdating = False

    For Each cell In Range("AU6:AU100")
    cell.EntireRow.Hidden = cell.Value = 0

    Application.ScreenUpdating = True

    Next cell

    End Sub



    Any help appreciated.


    Thanks in advance,


    Mike

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: hide row based on cell value in multiple sheets

    Hi Mike,

    Put the Application.ScreenUpdating = True after the Next Cell instruction.

    However can I also suggest an improvement. In general if you can avoid looping through cells by using another method then you should do so. Every pass through the loop requires the VBE to jump back to the Application, do something then jump back to the VBE. There is a time overhead every time this happens.

    My suggestion would be to use the macro to perform a standard Excel autofilter so that you custom filter the range for values that do not equal zero,
    This will be far quicker, especially with large ranges.

    Regards
    Last edited by Richard Buttrey; 05-13-2010 at 04:29 AM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: hide row based on cell value in multiple sheets

    Come on fatpiggy123

    We've been through all this before. What have you not done?
    Post again and let's get it right this time. Thread locked.

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

Closed 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