+ Reply to Thread
Results 1 to 3 of 3

Macro to Hide/Unhide Multiple Rows Based on Cell Value

Hybrid View

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    Florida, USA
    MS-Off Ver
    Excel 2013
    Posts
    7

    Macro to Hide/Unhide Multiple Rows Based on Cell Value

    I have a sheet with regions listed and a selector to choose whether or not to "enable" the region. If "yes" is selected, the value 1 is returned, if "no" is selected the value 0 is returned.

    I want to write the macro like the one below, but instead of listing the rows as ranges I need to refer to multiple, specific rows. Ex. 15, 18, 23.

    Private Sub Worksheet_Calculate()
    If Range("D7").Value = 0 Then
    Rows("15:25").Hidden = False                           Want to list specific rows here, not a range of rows
    End If
    
    If Range("D7").Value = 0 Then
    Rows("26:35").Hidden = True
    End If
    Thanks
    Last edited by Leith Ross; 05-14-2013 at 12:36 PM. Reason: Added Code Tags

  2. #2
    Forum Contributor ragavan.sridar1's Avatar
    Join Date
    11-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010, Excel 2003
    Posts
    208

    Re: Macro to Hide/Unhide Multiple Rows Based on Cell Value

    Try it like this..

    Range("9:9,13:13,17:17,20:20,23:23,26:26").Select
    Selection.EntireRow.Hidden = True
    Thanks!
    Raga.

    Please,mark your thread [SOLVED] if you received your answer.

    Click the little star * below, to give some Rep if you think an answer deserves it.

    I learnt so many things from these links.

  3. #3
    Registered User
    Join Date
    05-10-2013
    Location
    Florida, USA
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Macro to Hide/Unhide Multiple Rows Based on Cell Value

    This allowed me to hide the cells but excel crashes when the macro runs because it's so slow. Is there a way to code this w/o select?

+ 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