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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
Sub fusion()
Dim Fichier, WbCopy As Workbook, WbkColle As Workbook
Dim Colonnes(), Col As Integer, Resultat As Variant
Set WbColle = Workbooks.Open("/Users/Test.xlsx")
Sheets("Feuil1").Select
'nom des entetes de colonnes à importer
Colonnes = Array("Nom", "Prénom", "ID", "E-mail", "Téléphone portable", "Téléphone domicile", "Téléphone au travail")
Fichier = "/Users/Mailing_List.xlsx"
Set WbCopy = Workbooks.Open("/Users/Mailing_List.xlsx")
Sheets("Mailing_List").Select
With WbCopy.Sheets("Mailing_List")
For i = 1 To 5
'Boucle sur toutes les entêtes des colonnes
For Col = 1 To 7
'selectionne la première colonne
If Col = 1 Then 'Nom
'casse du dessous
ActiveCell.Offset(i, 0).Select
'Copié - Collé
Application.CutCopyMode = False
Selection.Copy
With WbColle.Sheets("Feuil1").Cells(i, 6).Offset(1, 0)
.PasteSpecial xlPasteValues
End With
End If
If Col = 2 Then 'Prénom
ActiveCell.Offset(0, 1).Select
Application.CutCopyMode = False
Selection.Copy
With WbColle.Sheets("Feuil1").Cells(i, 5).Offset(1, 0)
.PasteSpecial xlPasteValues
End With
End If
If Col = 4 Then 'Email
ActiveCell.Offset(0, 3).Select
Application.CutCopyMode = False
Selection.Copy
With WbColle.Sheets("Feuil1").Cells(i, 15).Offset(1, 0)
.PasteSpecial xlPasteValues
End With
End If
If Col = 5 Then 'Portable
ActiveCell.Offset(0, 1).Select
Application.CutCopyMode = False
Selection.Copy
With WbColle.Sheets("Feuil1").Cells(i, 13).Offset(1, 0)
.PasteSpecial xlPasteValues
End With
End If
If Col = 6 Then 'téléphone domicile
ActiveCell.Offset(0, 1).Select
Application.CutCopyMode = False
Selection.Copy
With WbColle.Sheets("Feuil1").Cells(i, 11).Offset(1, 0)
.PasteSpecial xlPasteValues
End With
End If
If Col = 7 Then 'téléphone travail
ActiveCell.Offset(0, 1).Select
Application.CutCopyMode = False
Selection.Copy
With WbColle.Sheets("Feuil1").Cells(i, 12).Offset(1, 0)
.PasteSpecial xlPasteValues
End With
End If
Next Col
Next
End With
Set WbCopy = Nothing
Set WbColle = Nothing
End Sub |
Partager