Coding Assistance With UserForm Using a Checkbox

  • Hello All,


    I'm trying to develop a Userform with text and a checkbox. I'm having problem with the coding.
    Here is the coding i have so far.



    Part of the code was taken from an example from online search. My problem is with the checkbox. How do I set it to code that when it is checked then it uses the second value line and unchecked it uses the first line value and then sends it to the cell next to the one being used to call the userform.


    Quick setup. Column D holds pull down menu. One option is called "Scope Report". If say cell D2 is used and Scope Report is pull up then the userform comes and the user fills in the information into txtjob and txtscope and either checks rev or not. The user then clicks add entry and cell E2 gets either the first value or second value.


    That is where I'm having problems, locating the checkbox info so the program and send the right info.

  • Re: Coding Assistance With UserForm Using a Checkbox


    Your code is confusing. In the Click Event handler for CheckBox1 you refer to the Enabled property of a control named cvRev and totally ignore the value of CheckBox1


    You define r as

    Code
    Dim r as String


    but then assign a value of 1 to it... and never assign any other value to it. So once it is set (assuming it actually does get set), it never gets unset.


    But why bother assigning a value to r? Why not simply query the Enabled property of cbRev in the code. Instead of

    Code
    If r <> 1 Then

    use

    Code
    If cbRev.Enabled = True
  • Re: Coding Assistance With UserForm Using a Checkbox


    thanks. I'm new to using userforms and checkboxs.
    I'll eliminate the first part and just try the second then you suggestion. I'll let you know if it works or not.

  • Re: Coding Assistance With UserForm Using a Checkbox


    Hey cytop. Thanks for the assistance. It works great. I made the change to the code like you suggested and now it works great. Here is the final code.



    Thanks for the assistance.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!