1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| Sub RefaireListes()
Dim I As Long, nbLignes As Long
Dim Liste As String
Liste = "a,b,c,d,e,f,g,h,i,j" 'Ta liste de choix originale
nbLignes = 10 'La dernière ligne contenant une liste de choix
Liste = ModifierListe(Liste)
For I = 2 To nbLignes '2 s'il y a des entêtes en ligne 1
If Range("A" & I) = "" Then
With Range("A" & I).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Liste
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End If
Next
End Sub
'On refait la liste de choix en éliminant les choix déjà inscrits
Function ModifierListe(Liste As String) As String
Dim I As Long
For I = 2 To 10 'Modifier au besoin
If Range("A" & I) <> "" Then
Liste = Replace(Liste, Range("A" & I), "")
End If
Next
Liste = Replace(Liste, ",,", ",")
ModifierListe = Liste
End Function |
Partager