SOLVED

Hide activebox when active box is checked

Copper Contributor

I'm trying to hide an Activebox when it's checked and visible when not. The code I was trying is this:

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
ActiveSheet.CheckBox1.Visible = False
Else
ActiveSheet.CheckBox1.Visible = True
End If

End Sub

 

 

Part2

Would like to have when one ActiveBox is checked another will show and if it's not check then the other ActiveBox will be hidden. 

6 Replies
best response confirmed by Nefe1930 (Copper Contributor)
Solution

@Nefe1930 

Perhaps like this?

Private Sub CheckBox1_Click()
    Me.CheckBox1.Visible = Not Me.CheckBox1.Value
    Me.CheckBox2.Visible = Me.CheckBox1.Value
    Application.EnableEvents = False
    Me.CheckBox2.Value = Not Me.CheckBox1.Value
    Application.EnableEvents = True
End Sub

Private Sub CheckBox2_Click()
    Me.CheckBox2.Visible = Not Me.CheckBox2.Value
    Me.CheckBox1.Visible = Me.CheckBox2.Value
    Application.EnableEvents = False
    Me.CheckBox1.Value = Not Me.CheckBox2.Value
    Application.EnableEvents = True
End Sub

@Hans Vogelaar 

Ok that works however when box 2 is clicked box 1 reappears. I'd like to have it if box 2 is clicked box 1 is still hidden, box 2 is hidden, and a new box is visible. 

@Nefe1930 

How many check boxes do you want to use?

Got alot! LOL doing up a form

@Nefe1930 

Private Sub CheckBox1_Click()
    If Me.CheckBox1.Value = True Then
        Me.CheckBox1.Visible = False
        Me.CheckBox2.Visible = True
        Application.EnableEvents = False
        Me.CheckBox2.Value = False
        Application.EnableEvents = True
    End If
End Sub

Private Sub CheckBox2_Click()
    If Me.CheckBox2.Value = True Then
        Me.CheckBox2.Visible = False
        Me.CheckBox3.Visible = True
        Application.EnableEvents = False
        Me.CheckBox3.Value = False
        Application.EnableEvents = True
    End If
End Sub

Private Sub CheckBox3_Click()
    If Me.CheckBox3.Value = True Then
        Me.CheckBox3.Visible = False
        Me.CheckBox4.Visible = True
        Application.EnableEvents = False
        Me.CheckBox4.Value = False
        Application.EnableEvents = True
    End If
End Sub
...
' Last one:

Private Sub CheckBoxn_Click()
    If Me.CheckBoxn.Value = True Then
        Me.CheckBoxn.Visible = False
    End If
End Sub
Thank you I'll try that in a min.
1 best response

Accepted Solutions
best response confirmed by Nefe1930 (Copper Contributor)
Solution

@Nefe1930 

Perhaps like this?

Private Sub CheckBox1_Click()
    Me.CheckBox1.Visible = Not Me.CheckBox1.Value
    Me.CheckBox2.Visible = Me.CheckBox1.Value
    Application.EnableEvents = False
    Me.CheckBox2.Value = Not Me.CheckBox1.Value
    Application.EnableEvents = True
End Sub

Private Sub CheckBox2_Click()
    Me.CheckBox2.Visible = Not Me.CheckBox2.Value
    Me.CheckBox1.Visible = Me.CheckBox2.Value
    Application.EnableEvents = False
    Me.CheckBox1.Value = Not Me.CheckBox2.Value
    Application.EnableEvents = True
End Sub

View solution in original post