+ Reply to Thread
Results 1 to 6 of 6

Hiding and unhiding column automaticaly when a cell value changes

Hybrid View

  1. #1
    evilrtc
    Guest
    I found this thread and I need something for a sheet I'm working on that is very similar. What I need to do though is hide an entire row if one cell in that row contains a certain word.

    How would I modify the above code to do this?

  2. #2
    Forum Contributor
    Join Date
    01-07-2004
    Posts
    192
    Assuming your one cell is A1 then you could use this.
    If Range("A1") = "your word" Then
    Range("A1").EntireRow.Hidden = True
    Else
    Range("A1").EntireRow.Hidden = False
    End If

  3. #3
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by evilrtc
    I found this thread and I need something for a sheet I'm working on that is very similar. What I need to do though is hide an entire row if one cell in that row contains a certain word.

    How would I modify the above code to do this?
    Hi,

    Try
    Sub Macro1()
    ' Hide Rows
    Dim iRow As Long
    Dim iLastRow As Integer
    With ActiveSheet
    iLastRow = ActiveSheet.Range("A65536").End(xlUp).Row
    For iRow = iLastRow To 1 Step -1
        If .Cells(iRow, 1) = "a certain word" Then
            .Rows(iRow).EntireRow.Hidden = True
        End If
        Next
        End With
    End Sub
    will work for the A cell of the row, but I'm not sure how that fits into a thread for columns.

    Do you need the code to test any other cells? - is the 'word' the only content of the cell? - you need to confirm what is required.

    hth
    ---
    Si fractum non sit, noli id reficere.

+ 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