Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jul 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hiding rows without selecting them (2002)

    I have a macro that hides or unhides rows that contain a named range when an image is clicked. It runs great but is a bit clunky visually. When the user executes the code, you actually see the rows bein selected and hiddin or unhidden. Is there a way to hide / unhide without actually selecting the rows? I tired using ScreenUpdating, but this didn't appear change things.

    Thanks in advance!
    Terry
    Seattle, WA

    -----------

    Private Sub CostMinus_Click()
    Application.ScreenUpdating = False
    Application.Goto Reference:="Costs"
    Selection.EntireRow.Hidden = True
    CostPlus.Visible = True
    CostMinus.Visible = False
    Application.ScreenUpdating = True
    End Sub

    Private Sub CostPlus_Click()
    Application.ScreenUpdating = False
    Application.Goto Reference:="Costs"
    Selection.EntireRow.Hidden = False
    CostPlus.Visible = False
    CostMinus.Visible = True
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hiding rows without selecting them (2002)

    ActiveWorkbook.Names("Costs").RefersToRange.Entire Row.Hidden = True

    You hardly ever have to do a select. HTH --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding rows without selecting them (2002)

    Try these:

    <pre>Private Sub CostMinus_Click()
    Application.ScreenUpdating = False
    Range("Costs").EntireRow.Hidden = True
    CostPlus.Visible = True
    CostMinus.Visible = False
    Application.ScreenUpdating = True
    End Sub

    Private Sub CostPlus_Click()
    Application.ScreenUpdating = False
    Range("Costs").EntireRow.Hidden = False
    CostPlus.Visible = False
    CostMinus.Visible = True
    Application.ScreenUpdating = True
    End Sub
    </pre>

    Legare Coleman

  4. #4
    New Lounger
    Join Date
    Jul 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding rows without selecting them (2002)

    Thank you, thank you! Works beautifully, and is something I can make use of in several other situations. One of the downsides of learning this stuff 'on the fly' is that you learn one, inefficient way to do something, but it works so you use it again and again. Thanks for this tip.

Posting Permissions

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