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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| Public Liste
Sub RefaireListes()
Dim I As Long
Dim ListeTemp As String
Liste = GetListeOptions
ListeTemp = ModifierListe(Liste)
For I = 19 To 28 'la liste des options Bateau
If Range("B" & I) = "" Then
With Range("B" & I).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=ListeTemp
.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 Variant) As String
Dim I As Long
Dim strTemp As String
For I = 1 To UBound(Liste)
If Liste(I, 1) <> "" Then strTemp = strTemp & Liste(I, 1) & ","
Next
strTemp = Left(strTemp, Len(strTemp) - 1)
For I = 19 To 28 'Modifier au besoin
If Range("B" & I) <> "" Then
strTemp = Replace(strTemp, Range("B" & I), "")
End If
Next
strTemp = Replace(strTemp, ",,", ",")
ModifierListe = strTemp
End Function
Function GetListeOptions() As Variant
Dim Colonne As Long
Dim nbLignes As Long
Dim Recherche As Range
Set Recherche = Sheets("Feuil3").Rows(1).Find(Range("B16"), LookIn:=xlValues, LookAt:=xlWhole)
If Not Recherche Is Nothing Then
Colonne = Recherche.Column
nbLignes = Sheets("Feuil3").Cells(2, Colonne).End(xlDown).Row
Sheets("Feuil3").Activate
GetListeOptions = Sheets("Feuil3").Range(Cells(2, Colonne), Cells(nbLignes, Colonne)).Value
Sheets("P B2 752").Activate
Else
GetListeOptions = 0
End If
Set Recherche = Nothing
End Function |