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
| Public Sub Recherche_Tél()
Dim début1 As Range, fin1 As Range, lazone1 As Range
Dim début2 As Range, fin2 As Range, lazone2 As Range
Dim c As Range
Dim nomcomplet2 As Range
'Nom complet Feuille1
With Sheets("Tableau1")
Set début1 = .Cells(3, 4)
Set fin1 = .Cells(.Rows.Count, 3).End(xlUp).Offset(0, 1)
Set lazone1 = .Range(début1, fin1)
With lazone1
.FormulaR1C1 = "=RC[-2]&RC[-1]"
.Value = .Value
End With
End With
''Nom complet Feuille1
With Sheets("Tableau2")
Set début2 = .Cells(3, 4)
Set fin2 = .Cells(.Rows.Count, 3).End(xlUp).Offset(0, 1)
Set lazone2 = .Range(début2, fin2)
With lazone2
.FormulaR1C1 = "=RC[-2]&RC[-1]"
.Value = .Value
End With
End With
'Recherche pour les numéros de téléphone manquants de la feuille1
'le nom complet dans la feuille 2 et retour du numéro de téléphone manquant
For Each c In lazone1.Offset(0, -3).SpecialCells(xlCellTypeBlanks)
nomcomplet1 = c.Offset(0, 3).Value
Set nomcomplet2 = lazone2.Find(nomcomplet1, LookIn:=xlValues)
If Not nomcomplet2 Is Nothing Then _
c.Value = nomcomplet2.Offset(0, -3).Value
Next c
'Effacement des cellules accessoires
lazone1.ClearContents
lazone2.ClearContents
'Variables réinitialisées
Set nomcomplet2 = Nothing
Set lazone2 = Nothing
Set fin2 = Nothing
Set début2 = Nothing
Set lazone1 = Nothing
Set fin1 = Nothing
Set début1 = Nothing
End Sub |
Partager