Hello, I have been searching on this topic for way too long and decided to just try my luck and see if anyone can help me. I couldn't find any code that matched exactly what I needed and I'm not savvy enough with VBA to figure out how to tailor it to my needs.
I have a worksheet with 4 checkboxes - Entry, Intermediate, Advanced, and Expert. I want to show/hide columns starting with Column C that have text in Row 3 matching the checkbox. So if Intermediate and Advanced checkboxes are checked, only columns with Intermediate or Advanced in C3 will be visible and columns with Entry or Expert will be hidden.
Any advice would be greatly appreciated!
Thanks![]()
Last edited by ksmoore; 11-09-2010 at 01:22 PM.
Without seeing your setup...etc this is the code for the checkbox named entry'Code supplied by Simon Lloyd '08/11/2010 'Microsoft Office Help Private Sub Entry_Change() Dim MyCell As Range, Rng As Range Set Rng = Me.Range("D1:G1") For Each MyCell In Rng If Me.Entry.Value = False And MyCell.Value = Me.Entry.Name Then MyCell.EntireColumn.Hidden = False End If If Me.Entry.Value = True And MyCell.Value = Me.Entry.Name Then MyCell.EntireColumn.Hidden = True End If Next End Sub
Not all forums are the same - seek and you shall find
Ok, great! It's almost there. With just one checkbox it works perfectly but I attempted to add the additional checkboxes and something is not right. I ran into something similar before and just added a line at the beginning showing all columns, but it is not working properly this time.
The code I have so far that follows the previous post is:
Any advice for how to update the sheet on each checkbox selection would be greatly appreciated!Dim MyCell As Range, Rng As Range Set Rng = Me.Range("C3:DD3") For Each MyCell In Rng If Me.CheckBox1.Value = False And MyCell.Value = "Entry" Then MyCell.EntireColumn.Hidden = True End If If Me.CheckBox1.Value = True And MyCell.Value = "Entry" Then MyCell.EntireColumn.Hidden = False End If If Me.CheckBox2.Value = False And MyCell.Value = "Intermediate" Then MyCell.EntireColumn.Hidden = True End If If Me.CheckBox2.Value = True And MyCell.Value = "Intermediate" Then MyCell.EntireColumn.Hidden = False End If If Me.CheckBox3.Value = False And MyCell.Value = "Advanced" Then MyCell.EntireColumn.Hidden = True End If If Me.CheckBox3.Value = True And MyCell.Value = "Advanced" Then MyCell.EntireColumn.Hidden = False End If If Me.CheckBox4.Value = False And MyCell.Value = "Expert" Then MyCell.EntireColumn.Hidden = True End If If Me.CheckBox4.Value = True And MyCell.Value = "Expert" Then MyCell.EntireColumn.Hidden = False End If Next End Sub
Thanks again.
How about posting the workbook? it'd be a lot easier![]()
Not all forums are the same - seek and you shall find
I figured out what I was doing wrong. I needed to make each checkbox an individual function (as the first solution shows), the code I posted would only update with changes to checkbox1. Thanks again!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks