+ Reply to Thread
Results 1 to 19 of 19

Hiding Rows Based On Value

  1. #1
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Hiding Rows Based On Value

    Hello,

    I have the following three macros that hide columns based on a range that has formulas in it flagging x's based on dates. The code works fine it is just very slow because it is going through cell by cell looking for an X. Is there a quicker way to write this so it hides columns with an X? Would I also be able to use that code similarly but hiding rows based on values down the row with x? I cannot use filters for this. It is a template that users need to be able to toggle back and forth. Grouping doesn't work because there is a macro to add rows and when the user does so it breaks the grouping so that it no longer groups correctly.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Hiding Rows Based On Value

    As always, Range.Find is your friend.

    Here's an example for ShowQtr:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Hiding Rows Based On Value

    Thanks walruseggman. When I run that macro nothing happens at all. It doesn't hide or show anything. It leaves the tab the same.
    Last edited by amartin575; 06-01-2015 at 02:24 PM.

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Hiding Rows Based On Value

    CAn you post the workbook, or an example workbook that replicates the problem?

  5. #5
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Hiding Rows Based On Value

    sure. See attached. There is a formula in rows 1 and two that runs a test on the period the workbook is for and drops x's in order to switch between the current quarter, month, year.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Hiding Rows Based On Value

    The code in place works it just takes a long time to complete and you can see the screen flash while it works. I would like it to be almost instant where the user doesn't even recognize it is moving through code.

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Hiding Rows Based On Value

    I didn't know there were formulas, and I missed that they could be capital X's, my bad.

    This runs in under 3/100ths of a second on my machine in your example you posted, so it shouldn't be noticeable.

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Hiding Rows Based On Value

    Try
    Please Login or Register  to view this content.
    Last edited by PCI; 06-01-2015 at 03:49 PM.
    - Battle without fear gives no glory - Just try

  9. #9
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Hiding Rows Based On Value

    Thanks again. It still is not working on my end. It runs fast but it doesn't hide anything.

  10. #10
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Hiding Rows Based On Value

    Do you have the code pasted in the right sheet object? Should be in Sheet1 in your example. Not sure what else. Runs fine for me, i see columns between D and CM hidden after the code runs.

  11. #11
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Hiding Rows Based On Value

    Thanks PCI. That doesn't seem to do anything either. I am going to reboot and see if the server I am logged into is having issues.

  12. #12
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Hiding Rows Based On Value

    I added it to the sheet itself as well as in a module and tried both. It runs but nothing changes. The file is 5,514kb otherwise I would post the live file so you could see.

  13. #13
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Hiding Rows Based On Value

    it is working now walruseggman but in reverse. It is hiding the columns with X's. I want it to hide the columns with " " instead. I will try changing that and let you know.

  14. #14
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Hiding Rows Based On Value

    But you could perhaps reduce the size of the file.
    Did you check with the file you sent?

  15. #15
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Hiding Rows Based On Value

    That didn't work. I can try changing the formula around so that it drops an X in the columns to hide and leaves the one to remain visible blank.

  16. #16
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Hiding Rows Based On Value

    I made certainly the same error and you have to change

    Please Login or Register  to view this content.
    by

    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Hiding Rows Based On Value

    Changing the formula around to put X's on columns to hide instead got your code to work the way I wanted. Thank you very much!

  18. #18
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Hiding Rows Based On Value

    PCI that change you suggested also worked. Thank you both again!

  19. #19
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Hiding Rows Based On Value

    And about treatment time is it good?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] hiding rows based on value
    By gingerhites in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-22-2014, 06:56 PM
  2. VBA Help | Hiding Rows based on Strings
    By maintguy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2012, 01:44 PM
  3. Hiding Rows Based based upon cell value being blank
    By leelee23 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-11-2007, 04:48 AM
  4. Hiding Rows Based on Results in Other Rows
    By clange2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2006, 04:57 PM
  5. Hiding rows based on a value
    By John in forum Excel General
    Replies: 1
    Last Post: 07-02-2005, 04:05 PM

Tags for this Thread

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