Radio Button output

S

sam

Hi All,

I have designed a form in excel with radio buttons 'Yes' And 'No'

How can I fill a cell with Yes if 'Yes' Radio button is selected and No if
'No' Radio button is selected?
Their Inputs of Yes and No are saved on an excel sheet, How can I progam it
such that every record is saved and displayed in Next cell

For eg: If on form I have a Question like:

Are you a Male?
o Yes
o No

The results are exported on excel sheet like:

User Inputs(column header)

Yes
Yes
No
Yes
No
No

Thanks is Advance
 
J

JLGWhiz

For the Yes button:

Private Sub CommandButton1_Click() 'Change button name
If CommandButton1.Value = True Then
ActiveCell = "Yes"
CommandButton1.Value = False
End If
End Sub

Same code for the other button, except ActiveCell = "No".
 
J

JLGWhiz

I am wondering if the first one will really give you everything yow wanted.
If you want a specified range to fill with the answers then maybe this
modified version would work better. Let's say we are using Column D for the
answer range.

Dim x As Long 'Outside the macro

Private Sub CommandButton1_Click() 'Change button name
If CommandButton1.Value = True Then
If x = Nothing Then x = 2
Range("D" & x) = "Yes"
CommandButton1.Value = False
x = x + 1
End If
End Sub

This way, x will update from either macro so that the answers will be in
sync with the questions. Unless, of course, they skip one. This assumes
row 1 will be a header row.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top