+ Reply to Thread
Results 1 to 11 of 11

Need help: Check box that hides columns in sheet2

  1. #1
    Registered User
    Join Date
    12-06-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Need help: Check box that hides columns in sheet2

    I've been searching and trying different things, but I keep running into errors. Basically I just need some VB code that will use a checkbox on sheet1 that when checked will show columns F:H on sheet 2, and when unchecked they will be hidden.

    (I rarely use macros/VB so I apologize if this is super easy)

    Thanks!
    Last edited by atflick; 01-29-2015 at 05:37 PM.

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Need help: Check box that hides columns in sheet2

    Change CheckBox21 to whatever your check box is named.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-06-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Need help: Check box that hides columns in sheet2

    I get an error "subscript out of range" on line: Set ws2 = Worksheets("Sheet2")

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Need help: Check box that hides columns in sheet2

    Do you have a sheet named "Sheet2" in that workbook? Change "Sheet2" to whatever the sheet name is of the sheet you want the columns hidden on.

  5. #5
    Registered User
    Join Date
    12-06-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Need help: Check box that hides columns in sheet2

    Now it says Object Required on this line If CheckBox1.Value = True Then ... I'm pretty sure the check box is named CheckBox1

  6. #6
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Need help: Check box that hides columns in sheet2

    Well that is the exact error I would expect if the checkbox wasn't named CheckBox1. Please verify the name by Entering Design Mode on the Developer tab, selecting the checkbox, right click --> Properties and look what is in the (Name) field.

    One other thought. I used an ActiveX checkbox, I don't believe a Form Control Checkbox will work with VBA, so make sure you're using ActiveX.

  7. #7
    Registered User
    Join Date
    12-06-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Need help: Check box that hides columns in sheet2

    What do I need for ActiveX, it doesn't look like I have that. Is it an add-on or something that's hidden from me at the moment?

  8. #8
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Need help: Check box that hides columns in sheet2

    ActiveX controls should be installed by default. See screenshot. You'd want the lower checkbox, under the ActiveX controls label.

    Edit: You can also see the check box name there on the left of the screen.

    AX.png

  9. #9
    Registered User
    Join Date
    12-06-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Need help: Check box that hides columns in sheet2

    OK yep, I'm an idiot. However it says I cannot insert... Searching it seems some update broke ActiveX controls and I need to delete some files. Does that mean anyone else who uses this file would also need to delete some files to use the checkboxes?

  10. #10
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Need help: Check box that hides columns in sheet2

    Ha, oh yeah, that was a huge error by Microsoft, and AFAIK they have yet to fix it, but they are aware of it.

    I don't believe it means anyone who uses that file would need to delete those files; it only has to do with inserting ActiveX controls, not using them, I think.

  11. #11
    Registered User
    Join Date
    12-06-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Need help: Check box that hides columns in sheet2

    Woohoo, got it to work now. Thank you so much!

+ 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. [SOLVED] Combo box selection hides columns that do not match
    By nadishon in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-06-2013, 09:24 AM
  2. Need a Macro that Hides Columns Based on Dates compared to Now()
    By yassiada in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2013, 08:29 PM
  3. Line that expands/hides columns
    By Analyst99 in forum Excel General
    Replies: 1
    Last Post: 03-13-2007, 08:25 AM
  4. [SOLVED] When i hide columns it hides whole sheet
    By CathyL in forum Excel General
    Replies: 1
    Last Post: 06-15-2006, 02:55 PM
  5. Button hides unhides columns, how?
    By JimH in forum Excel General
    Replies: 3
    Last Post: 04-20-2005, 05:06 PM

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