----------

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim KeyCells As Range
Dim Lg As Integer, Cl As Integer
Lg = ActiveCell.Row 'N° de ligne
Cl = ActiveCell.Column 'N° de colonne
If Target.Address = "$A$1" Then Exit Sub 'Elimine le traitement de la cellule A1 >>Prix
If Cl <> 1 Then Exit Sub 'Elimine le traitement des colonnes autres que 1
Set KeyCells = Cells(Lg - 1, 1)
If Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
Nom = Cells(Lg, 1)
Prénom = Cells(Lg, 2)
Tel = Cells(Lg, 4)
Fax = Cells(Lg, 5)
Texte = "Nom : " & Nom & " " & Prénom & vbCr & vbCr
Texte = Texte & "Tél. : " & Tel & vbCr
Texte = Texte & "Fax : " & Fax
Continue = MsgBox(Texte, vbOKOnly, "Téléphone & fax")
End If
Range("A1").Select
End Sub
Modifie par Modifié par Pegase le 20/06/20
----------

C'est assez simple, dans mon code il y a la lignele nom est dans colonne 2 et non 1
Lg représente le numéro de la ligne dans laquelle tu as double clique et le 1 qui suit est le n° de colonne : La fonction est Cells(n° de ligne,n° de colonne)Nom = Cells(Lg, 1)
Nom = Cells(Lg, 2)

Tel = Cells(Lg, 4)
Tel1 = Cells(Lg, 4)
Tel = "0" & Mid(Tel1, 1, 1) & " " & Mid(Tel1, 2, 2) & " " & Mid(Tel1, 4, 2) & " " & Mid(Tel1, 6, 2) & " " & Mid(Tel1, 8, 2)
----------
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim KeyCells As Range
Dim Lg As Integer, Cl As Integer
Lg = ActiveCell.Row 'N° de ligne
Cl = ActiveCell.Column 'N° de colonne
If Lg = 1 Then Exit Sub 'Elimine le traitement de la ligne 1
Set KeyCells = Cells(Lg - 1, 2)
If Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
Nom = Cells(Lg, 2)
Prénom = Cells(Lg, 3)
'Traitement n° de téléphone
'Lecture du n° de téléphone
Tel1 = Cells(Lg, 8)
If Tel1 = "" Then GoTo Suite1
'Mise au format 06 ss xx yy zz du n° de téléphone
Tel = "0" & Mid(Tel1, 1, 1) & " " & Mid(Tel1, 2, 2) & " " & Mid(Tel1, 4, 2) & " " & Mid(Tel1, 6, 2) & " " & Mid(Tel1, 8, 2)
Suite1:
'Traitement n° de Fax
Fax1 = Cells(Lg, 9)
If Fax1 = "" Then GoTo Suite2
Fax = "0" & Mid(Fax1, 1, 1) & " " & Mid(Fax1, 2, 2) & " " & Mid(Fax1, 4, 2) & " " & Mid(Fax1, 6, 2) & " " & Mid(Fax1, 8, 2)
Suite2:
'Traitement n° de portable
Port1 = Cells(Lg, 10)
If Port1 = "" Then GoTo Suite3
Port = "0" & Mid(Port1, 1, 1) & " " & Mid(Port1, 2, 2) & " " & Mid(Port1, 4, 2) & " " & Mid(Port1, 6, 2) & " " & Mid(Port1, 8, 2)
Suite3:
'Préparation du message
Texte = "Nom : " & Nom & " " & Prénom & vbCr & vbCr
Texte = Texte & "Tél. : " & Tel & vbCr
Texte = Texte & "Fax : " & Fax & vbCr
Texte = Texte & "Port : " & Port
'Affichage du message
Continue = MsgBox(Texte, vbOKOnly, "Téléphone & fax")
End If
'Positionnement de la cellule sélectionée en A1
Range("A1").Select
End Sub
Modifie par Modifié par Pegase le 22/06/20
----------
Le post anonyme est désactivé.
Merci de vous identifier
« Forum technique (liste des messages)9 enregistrements / page 1/1