Consulting

Results 1 to 5 of 5

Thread: Turning Checkboxes into Numeric Values

  1. #1
    VBAX Regular
    Joined
    Sep 2010
    Posts
    23
    Location

    Smile Turning Checkboxes into Numeric Values

    Excel 2007 - VBA Coding
    I have a userform that when the submit button is clicked dumps the data collected in the form onto a spreadsheet. Currently the checkboxes dump a "True/False" statement onto the spreadsheet. Userform has 24 checkboxes. I am wondering where/if I can have the "True/False" produce either a 1,0,-1 (number) based on the selection, rather then the "True/False." There are eight series of three checkboxes. Each series has a Yes-Checkbox, a No-Checkbox, a N/A checkbox. I'm thinking a Yes=1, No=-1, N/A=-1 from the overall count. (As in the question does not count as it doesn't apply.) The overall score is based on eight questions, or however many apply. (See attachment1 for Userform, this attachment also includes the VBA coding for the submit button on the userform)

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Something like this?

    Range("A4").Select
    Do
        If IsEmpty(ActiveCell) = False Then
            ActiveCell.Offset(1, 0).Select
        End If
    Loop Until IsEmpty(ActiveCell) = True
    ActiveCell.Value = cboNames.Value
        ActiveCell.Offset(0, 5) = IIf(CheckBox1.Value, 1, IIf(CheckBox2.Value, 0, IIf(CheckBox3.Value, -1, "")))
        ActiveCell.Offset(0, 6) = IIf(CheckBox4.Value, 1, IIf(CheckBox5.Value, 0, IIf(CheckBox6.Value, -1, "")))
        ActiveCell.Offset(0, 7) = IIf(CheckBox7.Value, 1, IIf(CheckBox8.Value, 0, IIf(CheckBox9.Value, -1, "")))
        ActiveCell.Offset(0, 8) = IIf(CheckBox10.Value, 1, IIf(CheckBox11.Value, 0, IIf(CheckBox12.Value, -1, "")))
        ActiveCell.Offset(0, 9) = IIf(CheckBox13.Value, 1, IIf(CheckBox14.Value, 0, IIf(CheckBox15.Value, -1, "")))
        ActiveCell.Offset(0, 10) = IIf(CheckBox16.Value, 1, IIf(CheckBox17.Value, 0, IIf(CheckBox18.Value, -1, "")))
        ActiveCell.Offset(0, 11) = IIf(CheckBox19.Value, 1, IIf(CheckBox20.Value, 0, IIf(CheckBox21.Value, -1, "")))
        ActiveCell.Offset(2, 5) = txtComments.Value
        ActiveCell.Offset(0, 1) = DTPicker1.Value
        ActiveCell.Offset(0, 3) = cboCoaches.Value
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,873
    I imagine the three checkboxes for each question are mutually exclusive? If so, do you have code behind them to ensure this? If not, may I suggest either you use option buttons which can easily be made mutually exclusive without code, or to use a single togglebutton, which can have three states corresponding to your n/a,yes/no. This last would mean you only have to look at as many controls as there are questions to get a score.
    I've started a bit of exploration of this but need to see some feedback to be sure I'm not on the wrong track.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    VBAX Regular
    Joined
    Sep 2010
    Posts
    23
    Location
    Exactly what I am looking for. Thank you XLD

  5. #5
    VBAX Regular
    Joined
    Sep 2010
    Posts
    23
    Location
    Thank you for the suggestions p45cal. I think I'm goin to roll with XLD above reply. Thanks for looking at the situation.

Posting Permissions

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