+ Reply to Thread
Results 1 to 4 of 4

Need VBA to hide columns based on text in a particular row

  1. #1
    Registered User
    Join Date
    11-20-2017
    Location
    Pennsylvania
    MS-Off Ver
    2016
    Posts
    3

    Need VBA to hide columns based on text in a particular row

    I am trying to create a series of checkboxes on one worksheet "Selections" that hide rows on another worksheet, "Data Table" when checked so that the Chart on "chart" worksheet only shows the series of data that I want it to show.
    I have accomplished this with the simple VBA of:

    Please Login or Register  to view this content.
    I attached this code to all 50 or so selection buttons that correspond to different columns in worksheet "Data Table".
    I also added a Select All button and Clear All button that work well.
    My problem is that if I add a column (new data series) to worksheet "Data Table" all of my checkboxes now point to the wrong column.
    So I was trying to figure out what VBA I should use so that it looks in worksheet "Data Table" in row 2 for specific text and then hides the column or columns that match that text.

    Any thoughts?

    Thank you.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Need VBA to hide columns based on text in a particular row

    Try:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    11-20-2017
    Location
    Pennsylvania
    MS-Off Ver
    2016
    Posts
    3

    Re: Need VBA to hide columns based on text in a particular row

    Thanks Mumps1 for the suggested VBA. This is what I found when I used it.
    When the checkbox was unchecked it hid the correct column but on the wrong worksheet. The column was hidden from the "Selections" worksheet rather than the "Data Table" worksheet. Also, when the checkbox was rechecked the column didn't unhide. If I then manually unhide the row, when I recheck the box, it hides it again, even though I need that row to hide when unchecked, and unhidden when checked.

    Any other thoughts?

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Need VBA to hide columns based on text in a particular row

    Could you attach a copy of your file? It would be easier to see how you data is organized and to test possible solutions.* Include a detailed explanation of what you want to do using a few examples from your data and referring to specific cells, sheets and workbooks.* De-sensitize the data if necessary.

+ 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. Hide Rows/Hide Columns Based on Value in Cell
    By brickwall823 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2015, 02:42 PM
  2. Hide columns based on cell value
    By jwillis07 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2014, 06:57 AM
  3. [SOLVED] Hide and unhide row and columns to change text in text boxes
    By Rocky2013 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-03-2013, 01:30 PM
  4. Hide columns based on value
    By LeonvL in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-21-2013, 09:32 AM
  5. [SOLVED] Hide Columns based on level of access e.g. if "Read Only" Hide G:G
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-16-2013, 06:10 AM
  6. Need to hide columns based on no or 0 value
    By freakycali in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 04-29-2013, 06:20 AM
  7. Hide columns based on value
    By arip in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2011, 05:28 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