+ Reply to Thread
Results 1 to 10 of 10

Looping hide row Optimization problem

  1. #1
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Looping hide row Optimization problem

    I am working with a fairly large dataset for which I am trying to develop the quickest code possible that will:
    1. Find the rows (from 10 to 16009) in the fourth column whose value =0
    2. Hide the entire row where this condition is true

    Here is the code I am working with, however it obviously very slow. I would appreciate any advice as to how to improve this or utilize a better method.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Looping hide row Optimization problem

    This will be much faster:

    Please Login or Register  to view this content.
    The speed comes from only "hiding" once!
    Gary's Student

  3. #3
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Looping hide row Optimization problem

    Thank you, it works much better! I see what you did by only hiding once. Since I want this to update the sheet each time the user navigates to it, I put the code back under the Worksheet_Activate() Private sub- which should not affect speed from what I can observe.

    How might I add a popup msgbox that would tell the user to wait while the page is update? Is it possible to include some sort of "time left" notification in this msgbox?

    Thanks again.

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Looping hide row Optimization problem

    I would display a TextBox before the loop runs and remove it after the loop runs.

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Looping hide row Optimization problem

    Is it possible that this approach might be faster?

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 04-09-2013 at 05:18 PM. Reason: Forgot to select column D

  6. #6
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Looping hide row Optimization problem

    Great thanks, I am experimenting with different ways of doing this but it is not a major issue.
    However relating to this row hide loop- I will need to add a filter to the dataset but it seems that the rows do not remain hidden whenever the data is filtered according to a column parameter and then reset back without the filter. Does applying/removing a filter always undo hidden rows? Is there any way to get around this?

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Looping hide row Optimization problem

    I forgot to select Column D.

    Sorry.

  8. #8
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Looping hide row Optimization problem

    Thank you for your solution Mehmetcik, however although it does run much quicker the code is not hiding the correct rows (those in column 4 which have a 0, between rows 10 and 16009). I think the issue with your solution lies in that it is selecting row 1 column 1 as the starting point- I am also hesitant about using Select as well as xlWhole which might seem to take longer to me, however please explain how this would be quicker.

  9. #9
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Looping hide row Optimization problem

    escobf,

    Another way (assumes data starts in column A and row 9 is a header row):
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  10. #10
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Looping hide row Optimization problem

    Hi

    I amended my code to only look at column D.

    The find function is in true vba code and will run faster then anything that has a loop.

    Try it and see which is faster.

    Do you have a timer programme?

+ 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