Bonjour
Trop de code à vérifier et le peu de test que j'ai fait donne de bon résultat
Juste une idée à vérifier avec une base de données plus importante
Dans tes procédures tu testes si la variable Ok est True et dans ce cas tu quittes
Moi je placerai Ok = True juste après cette ligne, car là où tu l'as placé "bloque" les autres procédures seulement si tu as trouvé une concordance mais dans le cas contraire tu modifies aussi tes ComboBox
En reprenant ta macro cela donnerait
Ligne ajoutée
Ligne enlevée
Modification de tes Combobox au cas où aucune occurrence de trouvée
Private Sub ComboBoxCodeGDO_Change()
Dim ligne As Range
Dim derlign As Long
If ok = True Then Exit Sub
[surligner=#FFFF80]ok = True
ComboBoxCentre.Enabled = False
ComboBoxSiteOperationnel.Enabled = False
ComboBoxAgenceExploit.Enabled = False
ComboBoxNomDépartHTA.Enabled = False
ComboBoxNomPoste.Enabled = False
ComboBoxCodeDépartHTA.Enabled = False
ComboBoxPoleExploit.Enabled = False
ComboBoxPPI.Enabled = False
ComboBoxNomPosteSource.Enabled = False
ComboBoxCommune.Enabled = False
ComboBoxRéglagePréconisé.Enabled = False
With Sheets("Registre départ PPI AFC")
derlign = .Range("F" & .Rows.Count).End(xlUp).Row
Set ligne = .Range("A3:AN" & derlign).Find(ComboBoxCodeGDO.Value)
If Not ligne Is Nothing Then
[surligner=#BFFFFF]'ok = True
ComboBoxCodeDépartHTA.Value = .Range("C" & ligne.Row)
ComboBoxCentre.Value = .Range("A" & ligne.Row)
ComboBoxNomPosteSource.Value = .Range("B" & ligne.Row)
ComboBoxPoleExploit.Value = .Range("E" & ligne.Row)
ComboBoxPPI.Value = .Range("G" & ligne.Row)
ComboBoxAgenceExploit.Value = .Range("AL" & ligne.Row)
ComboBoxNomDépartHTA.Value = .Range("D" & ligne.Row)
ComboBoxCodeGDO.Value = .Range("F" & ligne.Row)
ComboBoxNomPoste.Value = .Range("I" & ligne.Row)
ComboBoxCommune.Value = .Range("J" & ligne.Row)
ComboBoxSiteOperationnel.Value = .Range("AK" & ligne.Row)
ComboBoxRéglagePréconisé.Value = .Range("R" & ligne.Row)
Else
ComboBoxCentre.Enabled = True
ComboBoxSiteOperationnel.Enabled = True
ComboBoxAgenceExploit.Enabled = True
ComboBoxNomDépartHTA.Enabled = True
ComboBoxNomPoste.Enabled = True
ComboBoxCodeDépartHTA.Enabled = True
ComboBoxPoleExploit.Enabled = True
ComboBoxPPI.Enabled = True
ComboBoxNomPosteSource.Enabled = True
ComboBoxCommune.Enabled = True
ComboBoxRéglagePréconisé.Enabled = True
Me.ComboBoxNomDépartHTA = ""
Me.ComboBoxCodeDépartHTA = ""
Me.TextBoxNom = ""
Me.ComboBoxPPI = ""
Me.ComboBoxCentre = ""
Me.ComboBoxAgenceExploit = ""
Me.ComboBoxSiteOperationnel = ""
Me.ComboBoxRéglagePréconisé = ""
Me.ComboBoxPoleExploit = ""
Me.ComboBoxNomPosteSource = ""
End If
End With
ok = False
End Sub
A faire dans les autres procédures