Srbin do jaja
New Member
- Joined
- Sep 5, 2011
- Messages
- 7
here is the code i have and it works as a charm
but i have 10 option groups with 4 option button in each i was trying to make a function out of above example to:
when i run this function it gives me an error in line where
what am i doing wrong?
Code:
Private Sub CommandButton2_Click()
Dim LastRow As Object
Dim totalRows As Integer
Dim i As Integer
Dim x As Integer
Set LastRow = Sheet2.Range("B65536").End(xlUp)
If OptionButton1.Value = True Then
LastRow.Offset(1, 1).Value = OptionButton1.Caption
ElseIf OptionButton2.Value = True Then
LastRow.Offset(1, 1).Value = OptionButton2.Caption
ElseIf OptionButton1.Value = False And OptionButton2.Value = False Then
MsgBox "Answer the question: Kog ste pola"
Exit Sub
End If
End Sub
but i have 10 option groups with 4 option button in each i was trying to make a function out of above example to:
Code:
Private Sub getOptBtnValue()
x = 0
For i = 12 To 16
x = x + 1
If Controls("OptionButton" & i) = True Then
LastRow.Offset(1, 4).Value = Controls("OptionButton" & i).Caption
Exit For
End If
If x = 5 Then
MsgBox "Answer the question: Koliko ukupno imate radnog iskustva?"
Exit Sub
End If
Next i
End Sub
when i run this function it gives me an error in line where
Code:
LastRow.Offset(1, 4).Value = Controls("OptionButton" & i).Caption