PDA

View Full Version : Use check button enable/disable code lines



sindrefm
01-08-2015, 12:48 AM
Hi,

I want to use a check button, or any kind of toggle buttons, to enable and disable lines of code.
What I have done is the following:

Sheet2:

Private Sub CheckBox21_Click()
CodeLine = False
End Sub



Module1:

Sub Test()
Dim CodeLine As Boolean

CodeLine = True

If CodeLine = True Then
If .... then
End if
End if
End sub

To get this working like I have described, where should I place the CodeLine = True, to get the Checkbutton enable the False criteria right?

SamT
01-08-2015, 07:05 AM
Module1

Dim CodeLine As Boolean

Sub Test_CodeLione()
If CodeLine Then
do this code
End If
End Sub

Sub Initialize()
'Booleans are false when declared
CodeLine = True
End Sub


Sheet1

Sub ButtonNoCode_Click()
Module1.Codeline = False
End Sub

Sub ButtonToggleCode_Click()
With Module1
.Codeline = Not .Codeline
End With
End Sub

ThisWorkbook

Sub Workbook_Open
Run Module1.Initialize
End Sub

snb
01-08-2015, 10:30 AM
I don't think you need this, nor do I think you want this.
What are you trying to accomplish ?