Liste dépendante et vis versa
Hello,
J'ai cherché pour trouver une solution, mais sans succès: En fait, je ne sais même pas si c'est possible.
J'ai une liste déroulante qui contient des heures et une autre qui contient des pourcentages.
J'aurais besoin que quand je choisis une heure, la liste pourcentage se mette a jour (Selon une table de correspondance) et vis versa, si je met un pourcentage c'est l'heure qui se met à jour.
Si vous avez une piste sur le "comment faire" sans macro (Sinon du coup je passerais par VB)
Merci d'avance
g
Bonjour
Un essai à tester, si j'ai bien compris. Te convient-il ?
Option Explicit
Dim dico As Object, tablo, k
Dim i&, sformula$, h
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("C4:D4")) Is Nothing Then Exit Sub
Set dico = CreateObject("Scripting.Dictionary")
tablo = Range("K4").CurrentRegion
sformula = ""
If Target.Address = "$C$4" Then
For i = 1 To UBound(tablo, 1)
dico(CStr(Format(tablo(i, 1), "hh:mm:ss"))) = ""
Next i
k = dico.keys
For i = 0 To dico.Count - 1
sformula = sformula & "," & k(i)
Next i
Target.Validation.Delete
Target.Validation.Add Type:=xlValidateList, Formula1:=sformula
ElseIf Target.Address = "$D$4" Then
For i = 1 To UBound(tablo, 1)
dico(tablo(i, 2)) = ""
Next i
k = dico.keys
For i = 0 To dico.Count - 1
sformula = sformula & "," & k(i)
Next i
Target.Validation.Delete
Target.Validation.Add Type:=xlValidateList, Formula1:=sformula
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C4:D4")) Is Nothing Then Exit Sub
Application.EnableEvents = False
tablo = Range("K4").CurrentRegion
If Target.Address = "$C$4" Then
Range("D4").Validation.Delete
For i = 1 To UBound(tablo, 1)
If Target = tablo(i, 1) Then
Range("D4") = tablo(i, 2)
GoTo fin
End If
Next i
ElseIf Target.Address = "$D$4" Then
Range("C4").Validation.Delete
For i = 1 To UBound(tablo, 1)
If Target = tablo(i, 2) Then
Range("C4") = tablo(i, 1)
GoTo fin
End If
Next i
End If
fin:
Application.EnableEvents = True
End Sub
Sub Evenement()
Application.EnableEvents = True
End Sub
Bye !
Hey Génial merci !
Waouh, c'était plus compliqué que j'imaginais ! Tu as assuré. Je te remercie