Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2007

    Unanswered: Assign values to ratio buttons

    I have created a UserForm in Excel, to gather data for a questionnaire.

    For each question, the user must select an answer from a radio button (Yes, No and N/A)

    When I add the record (answers) to the sheet1, the results are shown as all being false.

    I want to show either ‘Yes’ or ‘No’ or ‘N/A’

    How do I do this????

    Private Sub CommandButton2_Click():
    Dim LastRow As Object
    Set LastRow = Sheet1.Range("a65536").End(xlUp)
    LastRow.Offset(1, 1).Value = UserForm1.OptionButton1.Value 
    LastRow.Offset(1, 1).Value = UserForm1.OptionButton2.Value
    LastRow.Offset(1, 1).Value = UserForm1.OptionButton3.Value
    End Sub

    Thanks in advance
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2003
    Amsterdam, Nederland


    depending on what for value you have given to the optionbuttons

    say : yes =1 no =2 and N/a =0

    you can do :

    Greetz Marvels -^.^-
    Developments : VB4 Through .Net; Basic; DOS ; CNC ; Sinclair
    Databases : SQL Server Through 2005; Access 3 Through 2003 ; Oracle 8 & 9.i ;
    OS : Win 3.11 Through XP ; NortonComander ; DOS

  3. #3
    Join Date
    Oct 2007
    I've used the code below to successfully assign the values from the caption of the radio button to the sheet.

    the answers of optionbutton1 to 3 works perfectly, but i have over 40 questions with the same three radio buttons...

    do i need to repeat the code for every questions, or is there any easy way to write it....

    i've grouped the three radio together, if that helps....

    please help

    Private Sub CommandButton2_Click():
    Dim LastRow As Range
    Dim strVal As String
        Set LastRow = Sheet1.Range("A65536").End(xlUp)
        Select Case True
            Case UserForm1.OptionButton1.Value
                strOpt = UserForm1.OptionButton1.Caption
            Case UserForm1.OptionButton2.Value
                strOpt = UserForm1.OptionButton2.Caption
            Case UserForm1.OptionButton3.Value
                strOpt = UserForm1.OptionButton3.Caption
        End Select
        LastRow.Offset(1, 1) = strOpt
    LastRow.Offset(1) = UserForm1.TextBox1.Value

  4. #4
    Join Date
    Oct 2003
    old, slow, and confused
    but at least I'm inconsistent!

    (retired Excel 2003 user, 3/28/2008)

    How to ask a question on forums

Posting Permissions

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