+ Reply to Thread
Results 1 to 6 of 6

VBA to hide rows based on different cells with different criteria

  1. #1
    Registered User
    Join Date
    09-28-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Post VBA to hide rows based on different cells with different criteria

    Hi Everyone,
    I am trying to hide entire rows based on whether there is a certain criteria in certain ranges (different criteria for different ranges, if that makes sense?)

    For example, I want to hide entire row IF Ranges L9:L10, L31:L33, L53:L56 = “H”
    and I also need to hide the rows IF Ranges B11:B30, B34:B52, B57:B60 = “Write Text Here”

    I have tried all sorts of things (albeit quite blindly as my understanding of vba is pretty basic). The code I am at now is the following and isn't working for me

    Please Login or Register  to view this content.
    any help would be appreciated, thank you in advance, Natalie

  2. #2
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: VBA to hide rows based on different cells with different criteria

    You were pretty close already
    When you select multiple ranges in the Range you have to put everything together in quotation marks not each range seperately
    And if you use the With activesheet you have to put a . in front of the range so that vba knows this range is refering to the activesheet.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-28-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: VBA to hide rows based on different cells with different criteria

    Sorry if this reply comes up twice, I replied and now I can't see that it posted

    that code now runs thanks LordLoki, however it will hide all the rows for the specified L ranges but only for B11:B30 range and not for anything else beyond that, so I have a bunch of rows that say "Write text here"?

    Is there something else I am missing at all?

  4. #4
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: VBA to hide rows based on different cells with different criteria

    Check if the cells really have the same Text than in your code (check for blanks etc).
    Also note its Case sensitive so if you want it to not care about the case try this

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-28-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: VBA to hide rows based on different cells with different criteria

    You did it, thank you so much (I had spent so much time trying to figure this out and you were exactly right, I hadn't thought about the case sensitivity of it at all)

    Hugely appreciated, thank you again

  6. #6
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: VBA to hide rows based on different cells with different criteria

    Happy that i could help

+ 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] Auto-hide/show Rows based on Yes/No Criteria
    By jakeruby in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-20-2015, 04:04 PM
  2. [SOLVED] hide rows, based criteria table
    By elsg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-03-2014, 05:35 PM
  3. Excel Macro/ VBA that can hide rows based on multiple criteria
    By hody in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-10-2012, 09:04 AM
  4. Macro - Hide/Unhide Rows based on conditional criteria
    By cklein in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2012, 02:23 PM
  5. Automatically hide rows based on criteria before printing
    By scaffdog845 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2011, 01:44 PM
  6. Hide/Unhide Rows based on Criteria
    By Phillycheese5 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-04-2010, 02:11 PM
  7. Hide Rows in Range based on criteria
    By Hot Soup in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-07-2009, 10:16 AM

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