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

    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????

    Code:
    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
    Location
    Amsterdam, Nederland
    Posts
    450

    re

    depending on what for value you have given to the optionbuttons

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

    you can do :

    if(A1=0;"N/A";if(A1=1;"Yes";"No"))
    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
    Posts
    127
    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

    Code:
    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
    Posts
    1,091
    old, slow, and confused
    but at least I'm inconsistent!

    Rich
    (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
  •