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
|
Sub SyncTGRISDIS() 'Construction
Dim DerLig_f2 As Long, a As Long
Dim ID As String
Dim x As Object
Dim EF1 As Workbooks 'Source
Dim F1 As Worksheet 'feuille source
Dim EF2 As Workbooks 'Cible
Dim F2 As Worksheet 'feuille Cible
'---Déclaration du TGRI sur la variable "F1" d'un classeur déja ouvert
Set EF1 = Workbooks("TGRI (Tableau de Gestion du réseau incendie).xlsm")
Set F1 = EF1.Worksheets("TGRI")
'---Déclaration du dossier "export SDIS" sur la variable "F2" d'un classeur déja ouvert
Set EF2 = Workbooks("Export donnée 10.12.2020.xlsx")
Set F2 = EF2.Worksheets("Feuil1")
'affectation du codde de localisation des source
Application.ScreenUpdating = False 'Evite les rafraîchissements de l'écran et augmente la vitesse d'exécution
DerLig_f2 = F2.Range("A" & Rows.Count).End(xlUp).Row 'Dernière ligne de la feuille 2
For a = 2 To DerLig_f2 ' la variable i prend successivement la valeur de la ligne 11 à la dernière ligne de la feuille 2
ID = F2.Cells(a, "A")
Set x = F1.Columns("K").Find(ID, LookIn:=xlValues, LookAt:=xlWhole) 'on recherche l'ID dans la colonne 2 (la B) de la feuille 1
If Not x Is Nothing Then 'si x n'est pas rien alors:
'pour chaque ligne i testée, on copie la plage qui va de la colonne B à la dernière colonne de la feuille 2 destination feuille 1 colonne B
'-----Identification-----
F2.Cells(a, "B") = F1.Cells(x.Row, "L") 'Commune
F2.Cells(a, "C") = F1.Cells(x.Row, "N") 'Adresse
F2.Cells(a, "D") = F1.Cells(x.Row, "Q") 'marque
F2.Cells(a, "E") = F1.Cells(x.Row, "R") 'model
F2.Cells(a, "F") = F1.Cells(x.Row, "S") 'renverssable
F2.Cells(a, "G") = F1.Cells(x.Row, "T") 'pi/bi
F2.Cells(a, "H") = F1.Cells(x.Row, "U") 'diamétre
F2.Cells(a, "I") = F1.Cells(x.Row, "V") 'satut
F2.Cells(a, "J") = F1.Cells(x.Row, "W") 'Anné de pose
F2.Cells(a, "K") = F1.Cells(x.Row, "X") 'type de réseau
F2.Cells(a, "L") = F1.Cells(x.Row, "Y") 'diamétre canalisation
F2.Cells(a, "M") = F1.Cells(x.Row, "Z") 'Lieux de la source
F2.Cells(a, "N") = F1.Cells(x.Row, "AA") 'Type de la source
F2.Cells(a, "O") = F1.Cells(x.Row, "AB") 'Volume de la source
F2.Cells(a, "P") = F1.Cells(x.Row, "AC") 'Surpresseur
F2.Cells(a, "Q") = F1.Cells(x.Row, "O") 'Position X
F2.Cells(a, "R") = F1.Cells(x.Row, "Y") 'Position Y
F2.Cells(a, "S") = F1.Cells(x.Row, "AD") 'Etat du Dispositif
'-----Controle Mécanique----
F2.Cells(a, "AA") = F1.Cells(x.Row, "AM") 'etat général
F2.Cells(a, "AB") = F1.Cells(x.Row, "AN") 'accés
F2.Cells(a, "AC") = F1.Cells(x.Row, "AO") 'manipulation
F2.Cells(a, "AD") = F1.Cells(x.Row, "AP") 'coffre
F2.Cells(a, "AE") = F1.Cells(x.Row, "AQ") 'oriantation
F2.Cells(a, "AF") = F1.Cells(x.Row, "AR") 'serrure
F2.Cells(a, "AG") = F1.Cells(x.Row, "AS") 'socle
F2.Cells(a, "AH") = F1.Cells(x.Row, "AT") 'carré de manoeuvre
F2.Cells(a, "AI") = F1.Cells(x.Row, "AU") 'bouchons
F2.Cells(a, "AJ") = F1.Cells(x.Row, "AV") 'raccord
F2.Cells(a, "AK") = F1.Cells(x.Row, "AW") 'vidange
F2.Cells(a, "AL") = F1.Cells(x.Row, "AX") 'clapet
F2.Cells(a, "AM") = F1.Cells(x.Row, "AY") 'ptotection
F2.Cells(a, "AN") = F1.Cells(x.Row, "AZ") 'BAC
F2.Cells(a, "AO") = F1.Cells(x.Row, "BA") 'vanne
'-----Signalisation-----
F2.Cells(a, "AP") = F1.Cells(x.Row, "BB") 'signalement du BI
F2.Cells(a, "AQ") = F1.Cells(x.Row, "BC") 'numérotation
F2.Cells(a, "AR") = F1.Cells(x.Row, "BD") 'peinture
'-----Gestion dossier----
F2.Cells(a, "AS") = F1.Cells(x.Row, "BE") 'date
F2.Cells(a, "AT") = F1.Cells(x.Row, "BG") 'sociétée
F2.Cells(a, "AU") = F1.Cells(x.Row, "BH") 'controleur
F2.Cells(a, "AV") = F1.Cells(x.Row, "BK") 'observation
F2.Cells(a, "AW") = F1.Cells(x.Row, "BL") 'controle impossible
'-----Controle hydraulique-----
F2.Cells(a, "T") = F1.Cells(x.Row, "AE") 'Débit requis
F2.Cells(a, "U") = F1.Cells(x.Row, "AF") 'Débit conforme
F2.Cells(a, "V") = F1.Cells(x.Row, "AG") 'Débit réglementaire
F2.Cells(a, "W") = F1.Cells(x.Row, "AH") 'pression statique
F2.Cells(a, "X") = F1.Cells(x.Row, "AI") 'pression dinamique
F2.Cells(a, "Y") = F1.Cells(x.Row, "AJ") 'debit a 1 BAR
F2.Cells(a, "Z") = F1.Cells(x.Row, "AL") 'Pression max
End If
Next a 'on passe à la valeur suivante de i
Application.ScreenUpdating = True
MsgBox "Syncronisation terminé", vbInformation, "Programme de Syncronisation TGRI vers Classeur excel SDIS"
End Sub |
Partager