+ Reply to Thread
Results 1 to 13 of 13

Hide and unhide certain rows with certain value

  1. #1
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Hide and unhide certain rows with certain value

    I'm not so good with coding...

    I need VBA macro for: a button that either hides or unhides rows when I click on it...
    So, if rows are already hidden, then this button unhides them.
    If those rows are not hidden, then it hides them.

    The criteria what rows to hide/unhide is:
    - Any rows that have the letter "r" within range ("C4:C350")

    Please help!
    Thanks!
    Last edited by nenadmail; 09-13-2012 at 01:03 PM.

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Hide and unhide certain rows with certain value

    Here try this

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: Hide and unhide certain rows with certain value

    Thanks a lot JieJenn!!! it works, but

    is there a way to make it go a little faster??? it seem like it's doing one row at a time...

    I have a similar macro for another project, but the difference is it hides when the cell is "blank" (and it only hides, it doesn't unhide)... I notice that it has a "Union" function in it, I think this is the key to make it go faster... is there a way you can incorporate a similar function into the code you wrote?
    Please Login or Register  to view this content.
    Last edited by nenadmail; 09-13-2012 at 01:26 PM.

  4. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Hide and unhide certain rows with certain value

    Hum... the macro runs pretty fast on my PC. Anyway try the revision then.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: Hide and unhide certain rows with certain value

    I timed it with the previous one and this one, they both take about 45 seconds (no difference)....
    I dunno how long it takes on your computer, but compared to the (sample code) that I posted earlier, which takes about 10 seconds..... 10 seconds sounds a lot better.

    I still think it may have to do with that "union" function... of course I'm no professional. Whatever it is, it's much faster. Maybe you can figure out what part of that (sample) code makes it faster?

    Thanks again for your help!

  6. #6
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Hide and unhide certain rows with certain value

    Mine took about 0.5 seconds.

  7. #7
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Hide and unhide certain rows with certain value

    I feel like I missing some really import information. Anyway, try again

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: Hide and unhide certain rows with certain value

    Well, its still about 45 seconds... I guess it's my computer.... if that's the fastest it can go, then I guess I'll have to live with that...

    Thanks for going the extra mile!

  9. #9
    Registered User
    Join Date
    09-13-2012
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Hide and unhide certain rows with certain value

    Hi, I would like to hide rows based on a cell value as well. I downloaded the example. I'm a complete technotard...but I'm learning. Basic question is, how do I get it to work in my workbook?

    The workbook is a quote generator based on details provided in worksheets. What I would like is for rows to be hidden where values in column BA are $0. Then, if there are changes to the selection forms, like adding an item to the quote, I'd like to be able to hide/unhide so those items appear. Ideally, I'd like a button on the "Quote" worksheet to hide/unhide instead of having to go to VB and 'run' the program. The effected rows are in two sections...first section is rows 33 - 96. Second section is rows 102-165. Is this possible or am I asking to do too much? Clear as mud?

    Thank you in advance for any assistance.

  10. #10
    Registered User
    Join Date
    09-13-2012
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Hide and unhide certain rows with certain value

    Here is a completed sample. THank you again!
    Last edited by Seifert; 09-17-2012 at 07:42 AM.

  11. #11
    Registered User
    Join Date
    09-13-2012
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Hide and unhide certain rows with certain value

    I think I figured it out. Thank you so much.

  12. #12
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Hide and unhide certain rows with certain value

    Hello Seifert, and welcome to the forum. Great to hear you figured it out but for your future posts please be aware of the following:

    You have inadvertently broken Rule #2 of the forum rules.

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

  13. #13
    Registered User
    Join Date
    09-13-2012
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Hide and unhide certain rows with certain value

    Rookie error.

+ 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