EXCEL Checkboxxx Props.

D

djayc53

I was hoping to create a spreadsheet in which i could have a workboo
appear/dissapear based on the status (checked/uncheckd) of a checkbox
have planted in the main workbook. I am familiar with VB, but not wit
excel macros and would very much appreciate the help. This is what
was thinking..

Sub CheckBox1_Click()
If Sheet1.Index(A1:J40, 2, 4) = "TRUE" Then
Sheet2.Visible = xlSheetVisible
Else
End If
If Sheet1.Index(A1:J40, 2, 4) = "FALSE" Then
Sheet2.Visible = xlSheetHidden
End If
End Sub

The cell referenced in the previous code (2, 4) is the cell that I hav
associated with the checkox. It's text is either TRUE or FALSE dependin
on the state of the box. I might be totally on the wrong track wit
this..

Please help. Thanks!

D
 
D

Dave Peterson

Maybe you could just use if the checkbox is checked or not:

Option Explicit
Private Sub CheckBox1_Click()
Sheet2.Visible = Not (Me.CheckBox1.Value)
End Sub

Or something like this:
Option Explicit
Private Sub CheckBox1_Click()
Sheet2.Visible = Not (Range(Me.CheckBox1.LinkedCell).Value)
End Sub

Or if you know the cell's location on the same sheet.

Option Explicit
Private Sub CheckBox1_Click()
Sheet2.Visible = Not (me.cells(2,4).Value)
End Sub

I like the first.
 
Top