Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("f6:f15")) Is Nothing Then Exit Sub
Cancel = True
With Combo1
.List = Array("Métropole 33", "988 Nouvelle-Calédonie 687", "987 Polynésie française 689", _
"974 La Réunion 262", "973 Guyane 594", "972 Martinique 596", "971 Guadeloupe 590")
.Left = Target.Offset(, 1).Left 'position horizontale
.Top = Target.Top 'position verticale
.Width = 202 'largeur
.Height = 1 'hauteur, pour masquer la zone de texte
.Text = "" 'RAZ
.Visible = True
End With
ThisWorkbook.Names.Add "MaCell", Target, Visible:=False 'nom défini masqué
Application.OnTime 1, Me.CodeName & ".Affiche" 'lance la macro
End Sub
Sub Affiche()
On Error Resume Next
Do
DoEvents
Me.Visible = xlSheetVisible 'si la feuille est masqiée
Application.Goto [MaCell].Offset(, -5) 'déplace la sélection en colonne A mais est-ce bien utile ???
Combo1.DropDown
Loop While Err = 0
Combo1.Activate: ActiveCell.Activate 'ferme la liste
ThisWorkbook.Names("MaCell").Delete 'sécurité
End Sub
Private Sub Combo1_Change()
If Not Combo1.MatchFound Then Exit Sub
Dim x$
ActiveCell(1, 6) = Right$(Combo1.Text, 3) & Right$(ActiveCell(1, 6), 9)
x = ActiveCell(1, 2) 'colonne B
x = Replace(Replace(x, " - Métropole", ""), " - Outre Mer", "")
Application.EnableEvents = False 'si c'est vraiment nécessaire...
ActiveCell(1, 2) = x & IIf(Left(ActiveCell(1, 6), 2) = "33", " - Métropole", " - Outre Mer")
Application.EnableEvents = True
ThisWorkbook.Names("MaCell").Delete 'arrête la boucle Do/Loop
End Sub