+ Reply to Thread
Results 1 to 3 of 3

Hide row based upon cell value

  1. #1
    Registered User
    Join Date
    06-28-2004
    Posts
    4

    Hide row based upon cell value

    From numerous sources, I have been able to get this code to work:

    Sub Unhide_and_Hide_Rows_based_upon_ColumnZ()

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

    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual 'pre XL97 xlManual
    Dim Rng As Range, ix As Long
    Set Rng = Intersect(Range("Z9:Z300"), ActiveSheet.UsedRange)
    For ix = Rng.Count To 1 Step -1
    If Trim(Replace(Rng.Item(ix).Text, Chr(160), Chr(32))) = "" Then
    Rng.Item(ix).EntireRow.Hidden = True
    End If
    Next
    done:
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    End Sub


    This code will look for "empty cells" within the Z9:Z300 range. If they are empty (incuding formulas that result in 0 or no value) the row is hidden. My next task is to redefine the range to Z9:Z43, Z50:75 and Z90:Z300. Can anyone help me change the code above so this range is affected? Thanks.
    jh

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525
    this may work but if you just want to see non blank cells, then you could use this code

    which activates the autofilter and filters out(hides) blank rows in column J


    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-28-2004
    Posts
    4

    Solved

    Thanks. However, I figured out a way for it to work with the existing code. In the cells rows within range Z39:Z300 that I did not want the macro to run, I simply put a value in the cell in white text (so it wouldn't show up in printing). That way my column header rows would hide if there wasn't a value in column Z. Simple, but effective.

+ 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