Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim cellule As Range
'---
If Not Intersect(Target, Range("B3:C7,B9:C19,B21:C25,B27:C30")) Is Nothing Then
For Each cellule In Range(Cells(Target.Row, 2), Cells(Target.Row, 3))
cellule.Value = Chr(161)
Next cellule
Target.Value = Chr(164)
Cells(Target.Row, 4).Select
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim R As Range
Dim R2 As Range
Dim C As Range
Dim k&
Dim cpt&
Dim x#
Dim Total#
Dim Plages As Variant
'--- Les plages concernées ---
Plages = Array("C3:C7", "C9:C19", "C21:C25", "C27:C30")
'--- Boucle sur chaque plage ---
For k& = LBound(Plages) To UBound(Plages)
Set R = Range(Plages(k&))
If Not Application.Intersect(Target, R) Is Nothing Then
cpt& = 0
'--- Les cellules valides ---
For Each C In R
If C = Chr(164) Then
cpt& = cpt& + 1
End If
Next C
'--- Les points en colonne E (Bx / 5) ---
Set R2 = R.Offset(-1, 2).Cells(1, 1)
Points# = CDbl(Mid(R2, InStr(1, R2, "/") + 1))
'--- Partage des notes et inscription du tirage ---
Set R2 = R.Offset(0, 2).Cells(1, 1)
x# = cpt& * (Points# / R.Rows.Count)
x# = Round(x#, 2)
Application.EnableEvents = False
R2 = CStr(x#) & Chr(160) & "/" & Chr(160) & CStr(Points)
Application.EnableEvents = True
End If
Next k&
'--- Total ---
For k& = LBound(Plages) To UBound(Plages)
Set R = Range(Plages(k&)).Offset(0, 2).Cells(1, 1)
Total# = Total# + CDbl(Mid(R, 1, InStr(1, R, Chr(160)) - 1))
Next k&
'--- Inscription du total en E31 ---
Application.EnableEvents = False
Range("E31") = Total#
Application.EnableEvents = True
End Sub