+ Reply to Thread
Results 1 to 4 of 4

Hide Rows using a check box dynamically.

  1. #1
    Registered User
    Join Date
    08-16-2013
    Location
    Kansas city
    MS-Off Ver
    Excel 2007
    Posts
    2

    Hide Rows using a check box dynamically.

    I am writing some documentation in excel. What I want to do is a hide a row (which I understand how to do). But what I am not sure how to do is assign the range of rows to hide dynamically. For example I have CheckBox1 locked to row A6 which hides range A1:A5. But then later I add 5 rows above A1, thereby moving the data in range A1:A5 to A5:A10 (including checkbox.) My problem is I am still left with the VBA hardcoded to A1:A5, so I am not hiding the correct range.

    Is there a variable I can use that references the cell value that the checkbox is located in? Or any other ideas of how to do this?

    Thanks for any help.

  2. #2
    Forum Contributor
    Join Date
    05-29-2013
    Location
    MD
    MS-Off Ver
    Excel 365
    Posts
    148

    Re: Hide Rows using a check box dynamically.

    I think you could use a named range - the references would change accordingly when you insert/delete rows/columns

    Thanks,
    Duncan

  3. #3
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Hide Rows using a check box dynamically.

    Will it always be all the rows above the checkbox?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  4. #4
    Registered User
    Join Date
    08-16-2013
    Location
    Kansas city
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Hide Rows using a check box dynamically.

    Quote Originally Posted by duncandhu View Post
    I think you could use a named range - the references would change accordingly when you insert/delete rows/columns

    Thanks,
    Duncan
    This resolved the issue. Thanks for the help. I selected the range of rows in the spreadsheet and name them then referenced that name in the VBA code and was able to hide that range.

    Thanks!

    Example:
    Select range, name using the name box (upper left hand corner of spreadsheet). Reference name in the VBA code, in this case "em_rw"

    Sub cb_hide_emrw()
    'This hides or shows certain cell ranges in the workplan dependent on which
    If Sheet8.Shapes("cl_accesscsm").ControlFormat.Value = 1 Then
    Sheet8.Range("em_rw").EntireRow.Hidden = True
    Else
    Sheet8.Range("em_rw").EntireRow.Hidden = False
    End If
    End Sub

+ 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. check box hide or unhide rows/column
    By makhdoomliaqat in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-28-2013, 08:15 AM
  2. Check boxes hide rows only during printing
    By donnyhurl in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-25-2012, 02:19 PM
  3. How to dynamically hide rows in a linked sheet?
    By megCAN in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-28-2012, 09:00 AM
  4. Using check boxes to hide and un-hide rows with drop down lists within rows
    By Sparky_Chris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2012, 07:22 AM
  5. Hide Rows/Show Rows - Check box
    By Audsmom in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2011, 03:02 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