Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,517
    Thanks
    37
    Thanked 67 Times in 63 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,731
    Thanks
    395
    Thanked 1,532 Times in 1,390 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,170
    Thanks
    151
    Thanked 587 Times in 559 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
  •