Thread: Survey Form
View Single Post
  #2   Report Post  
moondark
 
Posts: n/a
Default


Hi,

I created a Spreadsheet with the name "Start" and added 5 Optionbuttons
named "Choice1" to Choice"5" and a commandbutton to execute the code and
to vote.

The following code works but I'm not absolutely sure if it fits your
needs

Code:
--------------------
Private Sub CommandButton1_Click()
'Check if Spreadsheet "Result" exists
newone = True
For Each s In Sheets
If s.Name = "Result" Then newone = False
Next s
'if there's not such a sheet create it
If newone = True Then
Set ResultSheet = ActiveWorkbook.Worksheets.Add
ResultSheet.Name = "Result"
End If
'activate the sheet
Sheets("Result").Activate

'Fill in the values of the OptionButtons Where true = -1 and False = 0 _
so you have to subtract the value
Sheets("Result").Cells(1, 1) = Sheets("Result").Cells(1, 1) - Sheets("Start").Choice1.Value
Sheets("Result").Cells(2, 1) = Sheets("Result").Cells(2, 1) - Sheets("Start").Choice2.Value
Sheets("Result").Cells(3, 1) = Sheets("Result").Cells(3, 1) - Sheets("Start").Choice3.Value
Sheets("Result").Cells(4, 1) = Sheets("Result").Cells(4, 1) - Sheets("Start").Choice4.Value
Sheets("Result").Cells(5, 1) = Sheets("Result").Cells(5, 1) - Sheets("Start").Choice5.Value


End Sub
--------------------


it's rather simple and therefore not dynamic (,yet).
But I preferred plain code, you can learn from ;)

The code creates a Sheet called "Result" if it doesnt exist and writes
the values of the optionbuttons in Cells A1 to A5. I didnt work on
Headlines a.s.o. because everyone has his own design :)
You could also add a code fragment that checks if there is an
optionbutton selected (if not then msgbox("alert"))
something like that.


Regards,

Simon


--
moondark
------------------------------------------------------------------------
moondark's Profile: http://www.excelforum.com/member.php...o&userid=27390
View this thread: http://www.excelforum.com/showthread...hreadid=470660