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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
| '
' test_copie Macroi
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim Wk, FST, FS As Workbook
Dim derniere_ligne_FST As Integer
Dim i As Integer 'nombre de ligne rempli dans le tableau
Dim j As Integer 'permet de détacter la dernière cellule pleine du tableau
Dim dernier_ligne_tableau_FST As Integer
Dim Numero_contrat As Range
Dim Nom_affaire As Range
Dim Nom_client As Range
Dim Responsable As Range
Dim Commercial As Range
Dim mode As Range 'c'est le type dans la fiche de synthèse V2
Dim chef_secteur As Range
Dim Technicien As Range
Dim adresse_affaire1 As Range 'adresse
Dim adresse_affaire2 As Range 'code postal
Dim adresse_affaire3 As Range 'ville
Dim date_debut As Range
Dim duree As Range
Dim date_fin As Range
Dim tacite_reconductible As Range
Dim acces As Range
Dim nom_contact1 As Range
Dim nom_contact2 As Range
Dim fonction_contact1 As Range
Dim fonction_contact2 As Range
Dim tel_contact1 As Range
Dim tel_contact2 As Range
Dim fax_contact1 As Range
Dim fax_contact2 As Range
Dim portable_contact1 As Range
Dim portable_contact2 As Range
Dim mail_contact1 As Range
Dim mail_contact2 As Range
Dim montant_annuel_P1 As Range
Dim montant_annuel_P2 As Range
Dim montant_annuel_P3 As Range
Dim P1 As Range
Dim P2 As Range
Dim P3 As Range
Dim A_interessement As Range
Dim Disconnecteur As Range
Dim Legionnelle As Range
Dim Physico_chimique As Range
Dim Adoucisseur As Range
Dim Filtre_Courroie As Range
Dim Traitement_eau As Range
Dim Fluide_frigorigene As Range
Dim Piece_inferieur_a As Range
Dim Installation1 As Range
Dim Installation2 As Range
Dim Installation3 As Range
Dim Combustible1 As Range
Dim Combustible2 As Range
Dim Combustible3 As Range
Dim NB_Heure As Range
Dim delai_intervention As Range
Dim periodicite_visites As Range
Dim sous_traitance1 As Range
Dim sous_traitance2 As Range
Dim extension As String
Dim chemin As String
Dim nomfichier As String
'attribution et ouverture des différents classeurs
Set Wk = ThisWorkbook
fiche_de_synthèse_tbl = Wk.Sheets(1).Range("E10")
fiche_de_synthèse_feuille = Wk.Sheets(1).Range("E11")
Set FST = Workbooks.Open(fiche_de_synthèse_tbl)
Set FS = Workbooks.Open(fiche_de_synthèse_feuille)
'recherche des cellules dans FST
Set Numero_contrat = FST.Sheets("fiche de synthèse").Cells.Find(what:="CODE_SITE")
Set Nom_affaire = FST.Sheets("fiche de synthèse").Cells.Find(what:="Denomination")
Set Nom_client = FST.Sheets("fiche de synthèse").Cells.Find(what:="NOM_C")
Set Responsable = FST.Sheets("fiche de synthèse").Cells.Find(what:="Responsable")
Set Commercial = FST.Sheets("fiche de synthèse").Cells.Find(what:="Commercial")
Set mode = FST.Sheets("fiche de synthèse").Cells.Find(what:="Type_S")
Set chef_secteur = FST.Sheets("fiche de synthèse").Cells.Find(what:="Chef_de_secteur")
Set Technicien = FST.Sheets("fiche de synthèse").Cells.Find(what:="Technicien")
Set adresse_affaire1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="ADR1_S")
Set adresse_affaire2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="CP_S")
Set adresse_affaire3 = FST.Sheets("fiche de synthèse").Cells.Find(what:="VILLE_S")
Set date_debut = FST.Sheets("fiche de synthèse").Cells.Find(what:="DATE_DEBUT")
Set duree = FST.Sheets("fiche de synthèse").Cells.Find(what:="Duree_en_mois")
Set date_fin = FST.Sheets("fiche de synthèse").Cells.Find(what:="Date_de_fin")
Set tacite_reconductible = FST.Sheets("fiche de synthèse").Cells.Find(what:="RECONDUCTION")
Set acces = FST.Sheets("fiche de synthèse").Cells.Find(what:="COMMENTAIRE")
Set nom_contact1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="NOM2")
Set nom_contact2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="NOM3")
Set fonction_contact1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="fonction_1")
Set fonction_contact2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="fonction_2")
Set tel_contact1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="FIXE1")
Set tel_contact2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="FIXE2")
Set fax_contact1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="FAX1")
Set fax_contact2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="FAX2")
Set portable_contact1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="TEL1")
Set portable_contact2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="TEL2")
Set mail_contact1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="MAIL2")
Set mail_contact2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="MAIL3")
Set montant_annuel_P1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="Montant_Annuel_P1_HT")
Set montant_annuel_P2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="Montant_Annuel_P2_HT")
Set montant_annuel_P3 = FST.Sheets("fiche de synthèse").Cells.Find(what:="Montant_Annuel_P3_HT")
Set P1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="P1")
Set P2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="P2")
Set P3 = FST.Sheets("fiche de synthèse").Cells.Find(what:="P3")
Set A_interessement = FST.Sheets("fiche de synthèse").Cells.Find(what:="A_interessement")
Set Disconnecteur = FST.Sheets("fiche de synthèse").Cells.Find(what:="Disconnecteur")
Set Legionnelle = FST.Sheets("fiche de synthèse").Cells.Find(what:="Legionnelle")
Set Physico_chimique = FST.Sheets("fiche de synthèse").Cells.Find(what:="Physico-chimique")
Set Adoucisseur = FST.Sheets("fiche de synthèse").Cells.Find(what:="Adoucisseur")
Set Filtre_Courroie = FST.Sheets("fiche de synthèse").Cells.Find(what:="Filtre/Courroie")
Set Traitement_eau = FST.Sheets("fiche de synthèse").Cells.Find(what:="Traitement_eau")
Set Fluide_frigorigene = FST.Sheets("fiche de synthèse").Cells.Find(what:="Fluide_frigorigene")
Set Piece_inferieur_a = FST.Sheets("fiche de synthèse").Cells.Find(what:="Piece_inferieur_a")
Set Installation1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="Installation1")
Set Installation2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="Installation2")
Set Installation3 = FST.Sheets("fiche de synthèse").Cells.Find(what:="Installation3")
Set Combustible1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="Combustible1")
Set Combustible2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="Combustible2")
Set Combustible3 = FST.Sheets("fiche de synthèse").Cells.Find(what:="Combustible3")
Set NB_Heure = FST.Sheets("fiche de synthèse").Cells.Find(what:="PREVISION_TEMPS")
Set delai_intervention = FST.Sheets("fiche de synthèse").Cells.Find(what:="Delai_intervention")
Set periodicite_visites = FST.Sheets("fiche de synthèse").Cells.Find(what:="Periodicite_visites")
Set sous_traitance1 = FST.Sheets("fiche de synthèse").Cells.Find(what:="sous_traitance1")
Set sous_traitance2 = FST.Sheets("fiche de synthèse").Cells.Find(what:="sous_traitance2")
'copie et collage des cellules cherchées
j = 1
While FST.Sheets("Fiche de synthèse").Cells(j, 2) <> ""
j = j + 1
Wend
dernier_ligne_tableau_FST = j - 1
For i = 1 To dernier_ligne_tableau_FST
If Not Numero_contrat Is Nothing Then Numero_contrat.Offset(i).Copy FS.Sheets("ADM").Range("H2").MergeArea
If Not Nom_affaire Is Nothing Then Nom_affaire.Offset(i).Copy FS.Sheets("ADM").Range("U1").MergeArea
If Not Nom_client Is Nothing Then Nom_client.Offset(i).Copy FS.Sheets("ADM").Range("AE1").MergeArea
If Not Responsable Is Nothing Then Responsable.Offset(i).Copy FS.Sheets("ADM").Range("I3").MergeArea
If Not Commercial Is Nothing Then Commercial.Offset(i).Copy FS.Sheets("ADM").Range("V2").MergeArea
If Not mode Is Nothing Then mode.Offset(i).Copy FS.Sheets("ADM").Range("AD2").MergeArea
If Not chef_secteur Is Nothing Then chef_secteur.Offset(i).Copy FS.Sheets("ADM").Range("W3").MergeArea
If Not Technicien Is Nothing Then Technicien.Offset(i).Copy FS.Sheets("ADM").Range("AF3").MergeArea
If Not adresse_affaire1 Is Nothing Then adresse_affaire1.Offset(i).Copy FS.Sheets("ADM").Range("A6").MergeArea
If Not adresse_affaire2 Is Nothing Then adresse_affaire2.Offset(i).Copy FS.Sheets("ADM").Range("A7").MergeArea
If Not adresse_affaire3 Is Nothing Then adresse_affaire3.Offset(i).Copy FS.Sheets("ADM").Range("A8").MergeArea
If Not date_debut Is Nothing Then date_debut.Offset(i).Copy FS.Sheets("ADM").Range("P7").MergeArea
If Not duree Is Nothing Then duree.Offset(i).Copy FS.Sheets("ADM").Range("U7").MergeArea
If Not date_fin Is Nothing Then date_fin.Offset(i).Copy FS.Sheets("ADM").Range("AC7").MergeArea
If Not tacite_reconductible Is Nothing Then tacite_reconductible.Offset(i).Copy
FS.Sheets("ADM").Range("AH7").PasteSpecial Paste:=xlPasteValues
If Not acces Is Nothing Then acces.Offset(i).Copy FS.Sheets("ADM").Range("C10").MergeArea
If Not nom_contact1 Is Nothing Then nom_contact1.Offset(i).Copy FS.Sheets("ADM").Range("C13").MergeArea
If Not nom_contact2 Is Nothing Then nom_contact2.Offset(i).Copy FS.Sheets("ADM").Range("C18").MergeArea
If Not fonction_contact1 Is Nothing Then fonction_contact1.Offset(i).Copy FS.Sheets("ADM").Range("D14").MergeArea
If Not fonction_contact2 Is Nothing Then fonction_contact2.Offset(i).Copy FS.Sheets("ADM").Range("C19").MergeArea
If Not tel_contact1 Is Nothing Then tel_contact1.Offset(i).Copy FS.Sheets("ADM").Range("B15").MergeArea
If Not tel_contact2 Is Nothing Then tel_contact2.Offset(i).Copy FS.Sheets("ADM").Range("B20").MergeArea
If Not fax_contact1 Is Nothing Then fax_contact1.Offset(i).Copy FS.Sheets("ADM").Range("G15").MergeArea
If Not fax_contact1 Is Nothing Then fax_contact1.Offset(i).Copy FS.Sheets("ADM").Range("G20").MergeArea
If Not portable_contact1 Is Nothing Then portable_contact1.Offset(i).Copy FS.Sheets("ADM").Range("B16").MergeArea
If Not portable_contact2 Is Nothing Then portable_contact2.Offset(i).Copy FS.Sheets("ADM").Range("B21").MergeArea
If Not mail_contact1 Is Nothing Then mail_contact1.Offset(i).Copy FS.Sheets("ADM").Range("C17").MergeArea
If Not mail_contact2 Is Nothing Then mail_contact2.Offset(i).Copy FS.Sheets("ADM").Range("C22").MergeArea
If Not montant_annuel_P1 Is Nothing Then montant_annuel_P1.Offset(i).Copy FS.Sheets("ADM").Range("G24").MergeArea
If Not montant_annuel_P2 Is Nothing Then montant_annuel_P2.Offset(i).Copy FS.Sheets("ADM").Range("G25").MergeArea
If Not montant_annuel_P3 Is Nothing Then montant_annuel_P3.Offset(i).Copy FS.Sheets("ADM").Range("G26").MergeArea
If Not P1 Is Nothing Then P1.Offset(i).Copy
FS.Sheets("ADM").Range("M11").PasteSpecial Paste:=xlPasteValues
If Not P2 Is Nothing Then P2.Offset(i).Copy
FS.Sheets("ADM").Range("P11").PasteSpecial Paste:=xlPasteValues
If Not P3 Is Nothing Then P3.Offset(i).Copy
FS.Sheets("ADM").Range("T11").PasteSpecial Paste:=xlPasteValues
If Not A_interessement Is Nothing Then A_interessement.Offset(i).Copy
FS.Sheets("ADM").Range("W11").PasteSpecial Paste:=xlPasteValues
If Not Disconnecteur Is Nothing Then Disconnecteur.Offset(i).Copy
FS.Sheets("ADM").Range("S19").PasteSpecial Paste:=xlPasteValues
If Not Legionnelle Is Nothing Then Legionnelle.Offset(i).Copy
FS.Sheets("ADM").Range("S20").PasteSpecial Paste:=xlPasteValues
If Not Physico_chimique Is Nothing Then Physico_chimique.Offset(i).Copy
FS.Sheets("ADM").Range("S21").PasteSpecial Paste:=xlPasteValues
If Not Adoucisseur Is Nothing Then Adoucisseur.Offset(i).Copy
FS.Sheets("ADM").Range("S22").PasteSpecial Paste:=xlPasteValues
If Not Filtre_Courroie Is Nothing Then Filtre_Courroie.Offset(i).Copy
FS.Sheets("ADM").Range("AB19").PasteSpecial Paste:=xlPasteValues
If Not Traitement_eau Is Nothing Then Traitement_eau.Offset(i).Copy
FS.Sheets("ADM").Range("AB20").PasteSpecial Paste:=xlPasteValues
If Not Fluide_frigorigene Is Nothing Then Fluide_frigorigene.Offset(i).Copy
FS.Sheets("ADM").Range("AB21").PasteSpecial Paste:=xlPasteValues
If Not Piece_inferieur_a Is Nothing Then Piece_inferieur_a.Offset(i).Copy FS.Sheets("ADM").Range("Z22").MergeArea
If Not Installation1 Is Nothing Then Installation1.Offset(i).Copy FS.Sheets("ADM").Range("P15").MergeArea
If Not Installation2 Is Nothing Then Installation2.Offset(i).Copy FS.Sheets("ADM").Range("P16").MergeArea
If Not Installation3 Is Nothing Then Installation3.Offset(i).Copy FS.Sheets("ADM").Range("P17").MergeArea
If Not Combustible1 Is Nothing Then Combustible1.Offset(i).Copy FS.Sheets("ADM").Range("Y15").MergeArea
If Not Combustible2 Is Nothing Then Combustible2.Offset(i).Copy FS.Sheets("ADM").Range("Y16").MergeArea
If Not Combustible3 Is Nothing Then Combustible3.Offset(i).Copy FS.Sheets("ADM").Range("Y17").MergeArea
If Not NB_Heure Is Nothing Then NB_Heure.Offset(i).Copy FS.Sheets("ADM").Range("AK18").MergeArea
If Not delai_intervention Is Nothing Then delai_intervention.Offset(i).Copy FS.Sheets("ADM").Range("AK19").MergeArea
If Not periodicite_visites Is Nothing Then periodicite_visites.Offset(i).Copy FS.Sheets("ADM").Range("AJ20").MergeArea
If Not sous_traitance1 Is Nothing Then sous_traitance1.Offset(i).Copy FS.Sheets("ADM").Range("AH21").MergeArea
If Not sous_traitance2 Is Nothing Then sous_traitance2.Offset(i).Copy FS.Sheets("ADM").Range("AH22").MergeArea
'ici on enregistre et on ferme toutes les fiches de synthèse
extension = ".xlsx"
chemin = "F:\Alliaserv TPF\2eme macro copiecolle\"
nomfichier = "Fiche de synhèse_" & Nom_affaire.Offset(i) & extension
FS.SaveCopyAs Filename:=chemin & nomfichier
Next
FS.Close
FST.Close
Application.ScreenUpdating = True
End Sub |
Partager