+ Reply to Thread
Results 1 to 2 of 2

Option Button driven Macro to hide & unhide rows

  1. #1
    Registered User
    Join Date
    02-01-2012
    Location
    OH
    MS-Off Ver
    Excel 2010
    Posts
    3

    Option Button driven Macro to hide & unhide rows

    I have a group of 4 option buttons. Each option button relates to a group of three rows. Option button 1 is for rows 49-51. Option button 2 is for rows 53-55. Option button 3 is for rows 57-59. Option button 4 is for rows 61-63. I have cell C44 set as the linked cell for the option buttons, so that if option button 1 is chosen, then cell C44 displays the number 1, and if option button 2 is chosen, cell C44 displays the number 2, etc. Depending on which option button is chosen, I would like Excel to automatically display (i.e. unhide) 3 rows and hide the other 9 rows (i.e. the other 3 sets of 3 rows).

    I tried writing a macro and assigning it to the option buttons. The macro I tried to write is:

    Sub Hide_Unhide_Rows()
    If Target.Address = "$C$44" Then
    If Target.Value = "1" Then Rows("49:51").EntireRow.Hidden = False
    If Target.Value = "1" Then Rows("52:63").EntireRow.Hidden = True
    If Target.Value = "2" Then Rows("53:55").EntireRow.Hidden = False
    If Target.Value = "2" Then Rows("49:52").EntireRow.Hidden = True
    If Target.Value = "2" Then Rows("56:63").EntireRow.Hidden = True
    If Target.Value = "3" Then Rows("57:59").EntireRow.Hidden = False
    If Target.Value = "3" Then Rows("49:56").EntireRow.Hidden = True
    If Target.Value = "3" Then Rows("60:63").EntireRow.Hidden = True
    If Target.Value = "4" Then Rows("61:63").EntireRow.Hidden = False
    If Target.Value = "4" Then Rows("49:60").EntireRow.Hidden = True
    End If
    End Sub

    However, I get a run-time error '424'. Can anyone help?

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Option Button driven Macro to hide & unhide rows

    couldn't it be
    Please Login or Register  to view this content.
    ?

    Target.address is usually associated with a worksheet event.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Unhide/hide textbox with option button
    By wrybel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2016, 09:21 AM
  2. Required macro with button/option to hide unhide several sheets
    By vishpuj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2015, 06:43 AM
  3. [SOLVED] Need Option Button To Hide Or Unhide Worksheets
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-13-2014, 12:03 AM
  4. Button to Hide/Unhide rows
    By bullandbear in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-19-2013, 04:10 PM
  5. Excel 2007 : Hide and unhide rows using a button
    By littlefoot in forum Excel General
    Replies: 2
    Last Post: 11-28-2011, 06:10 AM
  6. Auto-hide certain rows (possibly macro driven)
    By bgreen in forum Excel General
    Replies: 1
    Last Post: 06-23-2009, 06:13 PM
  7. Button to hide and unhide rows
    By twofootgiant in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-13-2008, 04:37 AM

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