+ Reply to Thread
Results 1 to 6 of 6

Need to know what is wrong with this 3 line code (row hiding with conditional formati

  1. #1
    Registered User
    Join Date
    06-07-2006
    Location
    Montreal
    Posts
    73

    Need to know what is wrong with this 3 line code (row hiding with conditional formati

    I wish for this macro to hide every rows whch contains "info" in column B, but when I push the button associated with it, all rows becomes hidden. Any1 can help me with this?


    ActiveSheet.Columns("B").Select
    Selection.AutoFilter Field:=1, Criteria1:="info"
    Selection.EntireRow.Hidden = True

  2. #2
    Die_Another_Day
    Guest

    Re: Need to know what is wrong with this 3 line code (row hiding with conditional formati

    The rows that are filtered are still selected. Therefore when you hide
    selection you hide everything. Try this:

    Sub HideRows
    Dim cell as range
    for each cell in Range("B:B")
    if cell = "info" then Rows(cell.row).Hidden = True
    next
    end sub

    HTH

    Die_Another_Day

    Turquoise_dax wrote:
    > I wish for this macro to hide every rows whch contains "info" in column
    > B, but when I push the button associated with it, all rows becomes
    > hidden. Any1 can help me with this?
    >
    >
    > ActiveSheet.Columns("B").Select
    > Selection.AutoFilter Field:=1, Criteria1:="info"
    > Selection.EntireRow.Hidden = True
    >
    >
    > --
    > Turquoise_dax
    > ------------------------------------------------------------------------
    > Turquoise_dax's Profile: http://www.excelforum.com/member.php...o&userid=35185
    > View this thread: http://www.excelforum.com/showthread...hreadid=553660



  3. #3
    Registered User
    Join Date
    06-07-2006
    Location
    Montreal
    Posts
    73

    Exclamation

    This works fine to hide. However, I also have a "show all" button and it does not work after. Here is the (very short) code:

    Rows("1:100").Select
    Selection.EntireRow.Hidden = False

    When clicking, it does not unhide rows previously hidden (and in the range 1-100)

  4. #4
    Die_Another_Day
    Guest

    Re: Need to know what is wrong with this 3 line code (row hiding with conditional formati

    I'm not sure why that doesn't work. This seems to work for me:
    Rows("1:100").Hidden = False

    HTH

    Die_Another_Day

    Turquoise_dax wrote:
    > This works fine to hide. However, I also have a "show all" button and it
    > does not work after. Here is the (very short) code:
    >
    > Rows("1:100").Select
    > Selection.EntireRow.Hidden = False
    >
    > When clicking, it does not unhide rows previously hidden (and in the
    > range 1-100)
    >
    >
    > --
    > Turquoise_dax
    > ------------------------------------------------------------------------
    > Turquoise_dax's Profile: http://www.excelforum.com/member.php...o&userid=35185
    > View this thread: http://www.excelforum.com/showthread...hreadid=553660



  5. #5
    Registered User
    Join Date
    06-07-2006
    Location
    Montreal
    Posts
    73
    The row number are now all blue. What does it mean, and could it be indicative of the problem?

  6. #6
    Die_Another_Day
    Guest

    Re: Need to know what is wrong with this 3 line code (row hiding with conditional formati

    I think that means autoFiltering is still turned on.

    Die_Another_Day
    Turquoise_dax wrote:
    > The row number are now all blue. What does it mean, and could it be
    > indicative of the problem?
    >
    >
    > --
    > Turquoise_dax
    > ------------------------------------------------------------------------
    > Turquoise_dax's Profile: http://www.excelforum.com/member.php...o&userid=35185
    > View this thread: http://www.excelforum.com/showthread...hreadid=553660



+ 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