+ Reply to Thread
Results 1 to 8 of 8

Hide row if a cell value in the row does not equal one of values in a range

  1. #1
    Registered User
    Join Date
    10-11-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Hide row if a cell value in the row does not equal one of values in a range

    I am writing my first excel Macro so am keen and excited! However, I am having problems with the code. My objective is to first check whether any of the 6 values in cells H2:H7 are present in any of the cells in column B starting from cell B10. I want to hide the rows where the values are not present. This is the code I have come up with but I keep getting various errors. Any help would be much appreciated!!

    Please Login or Register  to view this content.
    Last edited by VBanal; 10-15-2013 at 07:34 PM. Reason: code tags added

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,945

    Re: Hide row if a cell value in the row does not equal one of values in a range

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (I have added them for you. Please add them in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    10-11-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Hide row if a cell value in the row does not equal one of values in a range

    Thanks for babysitting me on this one! Will keep in mind for future posts.

  4. #4
    Registered User
    Join Date
    10-11-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Hide row if a cell value in the row does not equal one of values in a range

    Hi,
    I want to hide rows where a particular cell in that row does NOT contain a particular value. When I run the code below, the following error is shown: Run-time error '424' Object required. How do I correct the code? Thanks very much

    Please Login or Register  to view this content.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,945

    Re: Hide row if a cell value in the row does not equal one of values in a range

    Try this instead:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-11-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Hide row if a cell value in the row does not equal one of values in a range

    This works, thanks very much!

    The above macro hides cells as long as data in column B does not match date in cell H2. I now want to provide the spreadsheet user guidence on what to fill in cell H2. This is very much like what one sees on "web forms" which prompt you to provide First Name, Middle Name, Last Name, Address and so forth. Guidance is provided in the text box itself but disappears when one clicks in to the text box. Can something similar be done on an xl spreadsheet?

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,945

    Re: Hide row if a cell value in the row does not equal one of values in a range

    Are you looking for some sort of data validation? Look at this link --

    http://office.microsoft.com/en-us/ex...010072600.aspx

  8. #8
    Registered User
    Join Date
    10-11-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Hide row if a cell value in the row does not equal one of values in a range

    Thanks. Very useful!

+ 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. Sum cells in a range based between two equal cell values in another range
    By sshone1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-09-2013, 08:12 AM
  2. Using cell values to define range of cells to hide
    By goosetopher in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-26-2013, 02:59 PM
  3. Replies: 0
    Last Post: 02-06-2013, 10:22 AM
  4. Replies: 17
    Last Post: 12-05-2012, 09:01 PM
  5. [SOLVED] Copying row or range if cell values are equal
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-18-2012, 09:24 AM

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