Check box and command button code

T

Todd

I have code like the following and it works almost like I
want it so that the cells will highlight in yellow when
you click on the command button however when I check the
checkbox it will activate the Form worksheet I have and
take the user over to that worksheet. I do not want
anything to happen until after the command button is
pressed. What can I add or remove to this code to allow
this to happen?
Thanks!

Option Explicit

Private Sub CommandButton1_Click()
Call CheckBox2_Click
End Sub

Private Sub CheckBox2_Click()
If Me.CheckBox2.Value = False Then Exit Sub
Sheets("Form").Activate
ActiveSheet.Range("Address").Select
If Selection.Interior.Pattern = xlNone Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else
With Selection.Interior
.Pattern = xlNone
End With
End If
End Sub
 
D

Dave Peterson

See one guess at your earlier post.
I have code like the following and it works almost like I
want it so that the cells will highlight in yellow when
you click on the command button however when I check the
checkbox it will activate the Form worksheet I have and
take the user over to that worksheet. I do not want
anything to happen until after the command button is
pressed. What can I add or remove to this code to allow
this to happen?
Thanks!

Option Explicit

Private Sub CommandButton1_Click()
Call CheckBox2_Click
End Sub

Private Sub CheckBox2_Click()
If Me.CheckBox2.Value = False Then Exit Sub
Sheets("Form").Activate
ActiveSheet.Range("Address").Select
If Selection.Interior.Pattern = xlNone Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else
With Selection.Interior
.Pattern = xlNone
End With
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top