+ Reply to Thread
Results 1 to 7 of 7

Hide Row depending on Cell Value

Hybrid View

  1. #1
    Registered User
    Join Date
    03-25-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    21

    Hide Row depending on Cell Value

    Hi There,

    I would like to run a macro that searches column [AS] and hides any rows in that column that contain "0", can anyone help?

    Thanks

    JM

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Hide Row depending on Cell Value

    Try this:

    Sub Hide_AS()
    Dim ws As Worksheet:    Set ws = Sheets("Sheet1") 'you may need to change this to match your sheet name
    Dim rCell As Range
    
    Application.ScreenUpdating = False
    ws.UsedRange.EntireRow.Hidden = False
    
    For Each rCell In ws.Range("AS1:AS" & ws.Range("AS" & Rows.Count).End(xlUp).Row)
        If rCell.Value = "0" Then
            rCell.EntireRow.Hidden = True
        End If
    Next rCell
    
    Application.ScreenUpdating = True
    
    End Sub

  3. #3
    Registered User
    Join Date
    03-25-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Hide Row depending on Cell Value

    Hi stnkynts,

    This works in theory - although I have over 3000 rows to check, so this way would take and absolute age to execute. Do you know of any faster ways?

    Regards,

    JM

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Hide Row depending on Cell Value

    Does this help?

    Sub JimMcEwan()
    Application.ScreenUpdating = False
    Range("AS1:AS" & Range("AS" & Rows.count).End(3)(1).Row).AutoFilter 1, "=0"
    Application.ScreenUpdating = True
    End Sub

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Hide Row depending on Cell Value

    Yeah, I could do it by autofilter, advancedfilter, reg expression. I wouldn't think the code would take that long to run though. How long did it take on your workbook?

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Hide Row depending on Cell Value

    @John, he would need to hide the 0's

    Range("AS1:AS" & Range("AS" & Rows.count).End(3)(1).Row).AutoFilter 1, "<>0"

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Hide Row depending on Cell Value

    Quote Originally Posted by stnkynts View Post
    @John, he would need to hide the 0's

    Range("AS1:AS" & Range("AS" & Rows.count).End(3)(1).Row).AutoFilter 1, "<>0"
    Oops. Good catch.

+ 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. How to show/hide row depending on cell value?
    By Haze1434 in forum Excel General
    Replies: 3
    Last Post: 03-03-2014, 06:10 PM
  2. hide unhide button depending on cell value
    By MarcoAUA in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-25-2012, 09:29 PM
  3. Hide a Tab Depending on Cell Value
    By julienT in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2011, 03:25 AM
  4. Macro to hide colums depending on another cell value
    By Badvgood in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2009, 08:08 AM
  5. Hide columns depending on a cell value?
    By rjmills18 in forum Excel General
    Replies: 2
    Last Post: 08-12-2008, 12:58 PM

Tags for this Thread

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