View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
lecaballero lecaballero is offline
external usenet poster
 
Posts: 5
Default Set optionbutton with range data doing Loop//For Each

Hi all,

First of all thanks you a lot, I am learning a lot from the people who helps
here!

I need to do a questionnire and I have designed a userform. Each answer has
4 optionbuttons to choose among 4 answers. There is 15 questions and I want
that anyone can see which option has been selected.

B c d e f g h i j
k l
Sup Ext Name Day ............... until 15 questions.........
1 3 aab
2 2 aac
3 1 aad <- Those are the answers
2 1 acd


To do that I have set this code:

If ActiveCell = 1 Then
optSup1 = True
ElseIf ActiveCell = 2 Then
optSup2 = True
ElseIf ActiveCell = 3 Then
optSup3 = True
Else
optSup4 = True
End If

So If in the cell there is a 1, I want the optSup1 to be checked, if its is
a 2 in the cell I need the optSup2 to be chosen and so on.

The problem is that the interview is going to be done several times and
there is a lot of questions and I need to do that with a loop. Could It be
possible to do something like that?



Dim i as integer




For i=1 to 5

If ActiveCell = i Then
optSup & i = True
Else
Exit Sub
End If

Next i


The problem is that a variable can not be concatenated and if I add quotes
the VBA does not recognize it as a variable.

Sorry if my english level is not very good

Thanks a lot in advance!!!