Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,469
    Thanks
    30
    Thanked 61 Times in 57 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 15:26.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 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
    2,820
    Thanks
    133
    Thanked 481 Times in 458 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
  •