+ Reply to Thread
Results 1 to 2 of 2

Trying to hide a row based on cell value within that row

  1. #1
    Registered User
    Join Date
    04-11-2013
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    2

    Trying to hide a row based on cell value within that row

    I want to hide rows based on the value of a cell in that row.
    If Cell Y506 is zero, then I want row 506 hidden. If the value in the cell is greater than zero, keep it unhidden.
    I then want to repeat this is for an entire range of cells (if cellXY=0, hide entire row, if cellXY>0, unhide row.)

    Also- I want to be able to use this code as a macro that I can use a button to activate. I do not want any rows to be hidden until the macro is activated/button is pressed.

    Very new to VBA, so all help is appreciated.

    Can anyone help?

    Thanks!

  2. #2
    Forum Contributor
    Join Date
    03-12-2013
    Location
    Chicago, USA
    MS-Off Ver
    Excel 2007
    Posts
    230

    Re: Trying to hide a row based on cell value within that row

    I'm writing this on a Mac so I can't test it, but does this work?

    Public Sub test()

    Dim i As Integer
    i = 0
    NumRows = Range("XY1", Range("XY1").End(xldown)).Rows.Count
    Range("XY1").Select

    Do Until i = NumRows
    If ActiveCell.Value = 0 Then
    Selection.EntireRow.Hidden = True
    Else
    Selection.EntireRow.Hidden = False
    End If
    ActiveCell.Offset(1,0).Select
    i + 1
    Loop
    End Sub

+ 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