Surveys

  • Thread starter Thread starter Enrique
  • Start date Start date
E

Enrique

I have developed a template with survey questions for
responses on a scale of 1 to 5. I would like to tally
eaach question/row once an option button is selected and
than create a sume of these questions.
 
for each question: Add a groupbox from the Forms toolbar. Add 5 optionbuttons
(also from the forms toolbar) completely within that groupbox.

Rightclick on any of the option buttons and choose format control. Then on the
control tab, select a nice linked cell (on the same row??).

Alternatively, you could add 5 optionbuttons from the controltoolbox toolbar.
But then you'll have to change the Groupname (rightclick|properties) to
something unique for each set of 5 optionbuttons.

Here's some code that you could use if you want to lay out the
buttons/groupboxes from the Forms toolbar:

Option Explicit
Sub testme01()

Dim grpBox As GroupBox
Dim optBtn As OptionButton
Dim maxBtns As Long
Dim myCell As Range
Dim myRange As Range
Dim wks As Worksheet
Dim i As Long

maxBtns = 5

Set wks = ActiveSheet
With wks
Set myRange = .Range("c4:c9")
myRange.EntireRow.RowHeight = 28
myRange.Resize(, maxBtns).EntireColumn.ColumnWidth = 4
.GroupBoxes.Delete
.OptionButtons.Delete
End With
For Each myCell In myRange
With myCell.Resize(1, maxBtns)
Set grpBox = wks.GroupBoxes.Add _
(Top:=.Top, Left:=.Left, Height:=.Height, _
Width:=.Width)
grpBox.Caption = ""
End With
For i = 0 To maxBtns - 1
With myCell.Offset(0, i)
Set optBtn = wks.OptionButtons.Add _
(Top:=.Top, Left:=.Left, Height:=.Height, _
Width:=.Width)
optBtn.Caption = ""
If i = 0 Then
optBtn.LinkedCell = myCell.Offset(0, -1).Address
End If
End With
Next i
Next myCell

End Sub
 
Back
Top