Excel Checkbox Tool Built with VBA

Finanzias

New Member
Joined
Apr 22, 2018
Messages
2
All,

I have a workbook that has TRUE or FALSE values in row 4. These true or false cells are linked to checkboxes in row 3 above. There are two distinct functions that I'm trying to achieve.

1.) I'm trying to create code that hides each column with a FALSE value in row 4 (hiding all columns with unchecked boxes). Another complexity is that it needs to hide the checkbox as well so that there aren't a bunch of rogue checkboxes after the columns are hidden. It also needs to be dynamic as columns are added and deleted. My work in process code is:


Code:
Sub HideColumns()

Dim xRange As Range
Set xRange = Cells(4, 2).End(xlToRight)
Set xRange = Range(Range("b4"), xRange)


With xRange
If Cells.Value = "FALSE" Then
Columns.EntireColumn.Hidden
End With


End Sub


2.) I also want to create another set of code that will uncheck all boxes in row 2, unhide all columns, and unhide all checkboxes thus returning everything to it's original form. I've tried to do this by changing all values in row 4 to false which unchecks the box.

Code:
Sub UncheckAllBoxes()

'uncheck boxes
Dim xRange As Range
Set xRange = Cells(4, 2).End(xlToRight)
Set xRange = Range(Range("b4"), xRange)


With xRange
If Cells.Value = "TRUE" Then Cells.Value = "FALSE"


End With


'unhide all columns
Columns.EntireColumn.Hidden = False


'uncheck all checkboxes???


End Sub

Thanks in advance!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,216,102
Messages
6,128,849
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top