Results 1 to 8 of 8

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

Threaded View

  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!!

    Sub HideRows()
        
        Dim ISIN As Range
        Dim MyRow As Long
        Dim MyColumn As Long
        
        Set ISIN = Range("H2:H7")
        Set MyRow = 10
        Set MyColumn = 2
        
        Worksheets("Product Monitor").Activate
        
        If Cells(MyRow, MyColumn).Value = Not (ISIN) Then
        Rows(MyRow).EntireRow.Hidden = True
        MyRow = MyRow + 1
        
        End If
    End Sub
    Last edited by VBanal; 10-15-2013 at 07:34 PM. Reason: code tags added

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