Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,579
    Thanks
    44
    Thanked 76 Times in 71 Posts

    Macro to hide rows based on cell value

    Client wants to use: CTRL+Shift+T as a kb shortcut to hide all the rows in the sheet where the value in column D is <80%.

    Is this the best way?

    Sub HideRows()
    Dim LRow As Long
    LRow = Cells(Rows.Count, "C").End(xlUp).Row
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    For x = LRow To 1 Step -1
    If Cells(x, "C").Value < 0.8 Then
    Rows(x).Hidden = True
    End If
    Next
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    End Sub
    Last edited by kweaver; 2013-09-02 at 14:26.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,958
    Thanks
    422
    Thanked 1,606 Times in 1,450 Posts
    Kevin,

    See the discussion here. HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    3,418
    Thanks
    165
    Thanked 643 Times in 611 Posts
    Hi Kweaver

    ..what if there are some hidden rows already, where the value in col [D] is >80%?????
    ..your routine would ignore this, (i.e. won't 'unhide' them) so may not display all the 'correct' rows.
    So, I would first unhide ALL rows, then continue the routine to hide the relevant rows.
    see the discussion as suggested by RG

    zeddy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •