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
|
Private Sub TextBox1_AfterUpdate()
Dim AireGestionEnCours As Range
Dim Continuer As Boolean
With Me
.TextBox2 = "": .TextBox3 = "": .TextBox4 = "": .TextBox5 = ""
End With
Continuer = False
If WorksheetFunction.CountIf(Sheets("GESTION A").Range("A:A"), Me.TextBox1.Value) > 0 Then
Set AireGestionEnCours = Sheets("GESTION A").Range("SOURCEA")
Continuer = True
End If
If WorksheetFunction.CountIf(Sheets("GESTION B").Range("A:A"), Me.TextBox1.Value) > 0 Then
Set AireGestionEnCours = Sheets("GESTION B").Range("SOURCEB")
Continuer = True
End If
If WorksheetFunction.CountIf(Sheets("GESTION C").Range("A:A"), Me.TextBox1.Value) > 0 Then
Set AireGestionEnCours = Sheets("GESTION C").Range("SOURCEC")
Continuer = True
End If
If Continuer = False Then
MsgBox "Cette adresse n'existe pas. Veuillez ressaisir une nouvelle adresse", vbInformation + vbOKOnly, "Adresse non trouvée"
Exit Sub
End If
With Me
.TextBox2 = Application.WorksheetFunction.VLookup((Me.TextBox1), AireGestionEnCours, 2, 0)
.TextBox3 = Application.WorksheetFunction.VLookup((Me.TextBox1), AireGestionEnCours, 3, 0)
.TextBox4 = Application.WorksheetFunction.VLookup((Me.TextBox1), AireGestionEnCours, 4, 0)
.TextBox5 = Application.WorksheetFunction.VLookup((Me.TextBox1), AireGestionEnCours, 6, 0)
End With
Set AireGestionEnCours = Nothing
End Sub |
Partager