Voici une adaptation de ma précédente proposition pour permettre et limiter le nombre de réponses à 2 par question, reposant sur le code suivant :
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
With Range("QCU")
If Not Intersect(Target, .Cells) Is Nothing Then
ligne = Target.Row - .Row + 1
lettre = Split(Target.Value, ".")(0)
profil = Evaluate("INDEX(Profils[#Headers],MATCH(""" & lettre & """,OFFSET(Profils," & ligne - 1 & ",1,1,4),0)+1)")
pos = Application.Match(profil, [Choix].Columns(1), 0)
If Target.Interior.Color = vbGreen Then
Target.Interior.Color = xlNone
[Choix].Cells(pos, 2) = [Choix].Cells(pos, 2) - 1
Else
If SUMCOLOR(.Rows(ligne), vbGreen) < 2 Then
Target.Interior.Color = vbGreen
[Choix].Cells(pos, 2) = [Choix].Cells(pos, 2) + 1
End If
End If
End If
End With
End Sub
Function SUMCOLOR(r As Range, Optional Color As Long = xlNone) As Long
With r
For i = 1 To .Cells.Count
If .Cells(i).Interior.Color = Color Then SUMCOLOR = SUMCOLOR + 1
Next i
End With
End Function
Un tableau a été remplacé. Ce nouveau tableau peut être déplacé en feuille 2. Le tableau principal (cible des clics) doit rester en feuille 1.
Cdlt,