+ Reply to Thread
Results 1 to 5 of 5

Hide or Unhide Rows base on value in row

Hybrid View

  1. #1
    Registered User
    Join Date
    02-15-2013
    Location
    Orange, CA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Hide or Unhide Rows base on value in row

    I need to hide an entire row if a particular field has 2011 in it. Is this possible?
    Last edited by jeffreybrown; 02-15-2013 at 09:12 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Hide or Unhide Rows base on value in row

    Sure, this is possible, but a few more details would help...

    When do you want the hide to happen? Only when you press a button or what?

    How or when do you want the rows unhidden?
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    02-08-2013
    Location
    Louisiana, USA
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Hide or Unhide Rows base on value in row

    Here is some code that I use to accomplish this, although I have the criteria to hide as a variable that is populated by an Inputbox that way I can use it in more that one spreadsheet.

    This will work over multiple columns.

    If you highlight only column B, run the code and enter 2011 you will have 1001 to 1009.

    If you highlight columns B, C, and D, run the code and enter 2011 you will have 1001, 1003, 1005, 1007, 1009

    I hope this helps you out.

    HideRowsbasedonUserSelectionandInput.xls

  4. #4
    Registered User
    Join Date
    02-15-2013
    Location
    Orange, CA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Hide or Unhide Rows base on value in row

    I want to hide an entire row once a particular column of said row has 2011. Example: I want to hide row 5 once "G5" contains 2011 (btw, it won't only be 2011 - it could be 05/31/2011, 06/30/2011, etc.) I want this to be true for the entire spreadsheet - if G-whatever the corresponding row is contains 2011, then I want it hidden.

    Hopefully this makes more sense.

    Thank you for your assistance.

  5. #5
    Registered User
    Join Date
    02-08-2013
    Location
    Louisiana, USA
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Hide or Unhide Rows base on value in row

    I have made changes to the code so that if 2011 or a date such as 05/01/2011 is in a cell then the entire row will be hidden.

    HideRowsbasedonUserSelectionandInput(MatchStringorYear).xlsm

    Sub Macro1()
    'The user has to have a range selection or nothing will happen
    
    Dim Strng As String
    
    Strng = InputBox("Enter the string to be hidden")
    
    Application.ScreenUpdating = False
        
    On Error Resume Next
    Selection.SpecialCells(xlCellTypeConstants, 23).Select
        
        For Each cell In Selection
            
            If cell.Value = Strng Or Year(cell) = Strng Then
            cell.EntireRow.Hidden = True
            Else
            End If
        Next cell
        
    Application.ScreenUpdating = True
    
    End Sub
    I have also changed a couple of cells to the month/day/year format. I hope this helps.

+ 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