Consulting

Results 1 to 3 of 3

Thread: Use check button enable/disable code lines

  1. #1
    VBAX Regular
    Joined
    Nov 2014
    Posts
    47
    Location

    Use check button enable/disable code lines

    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?

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    I don't think you need this, nor do I think you want this.
    What are you trying to accomplish ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •