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
| Sub ExportExcel()
Dim Plage As Range
Dim Array1 As Variant
Dim x As Variant
Dim Db1 As Database
Dim Rs1 As Object
' Opening database
Set Db1 = DBEngine.OpenDatabase(DBEXPORT)
'Open SaveMatrix table
Set Rs1 = Db1.OpenRecordset("Save_Matrix", dbOpenDynaset)
Set Plage = Worksheets("SaveMatrix").Range("A1").CurrentRegion.Offset(1, 0)
Set Plage = Plage.Resize(Plage.Rows.Count - 1, Plage.Columns.Count)
Array1 = Plage.Value
For x = 1 To UBound(Array1, 1)
With Rs1
.AddNew
.Fields("ID_Action") = Array1(x, 1)
.Fields("Compilance_Conse") = Array1(x, 2)
.Fields("Compilance_Freq") = Array1(x, 3)
.Fields("Safety_Conse") = Array1(x, 4)
.Fields("Safety_Freq") = Array1(x, 5)
.Fields("Environment_Conse") = Array1(x, 6)
.Fields("Environment_Freq") = Array1(x, 7)
.Fields("Integrity_Conse") = Array1(x, 8)
.Fields("Integrity_Freq") = Array1(x, 9)
.Fields("SCE_Conse") = Array1(x, 10)
.Fields("SCE_Freq") = Array1(x, 11)
.Fields("Financial_Conse") = Array1(x, 12)
.Fields("Financial_Freq") = Array1(x, 13)
.Fields("Media_Conse") = Array1(x, 14)
.Fields("Media_Freq") = Array1(x, 15)
.Fields("LevelCompil_Conse") = Array1(x, 16)
.Fields("LevelFreq_Conse") = Array1(x, 17)
.Fields("LevelSafety_Conse") = Array1(x, 18)
.Fields("LevelSafety_Freq") = Array1(x, 19)
.Fields("LevelEnvi_Conse") = Array1(x, 20)
.Fields("LevelEnvi_Freq") = Array1(x, 21)
.Fields("LevelIntegrity_Conse") = Array1(x, 22)
.Fields("LevelIntegrity_Freq") = Array1(x, 23)
.Fields("LevelSCE_Conse") = Array1(x, 24)
.Fields("LevelSCE_Freq") = Array1(x, 25)
.Fields("LevelFinancial_Conse") = Array1(x, 26)
.Fields("LevelFinancial_Freq") = Array1(x, 27)
.Fields("LevelMedia_Conse") = Array1(x, 28)
.Fields("LevelMedia_Freq") = Array1(x, 29)
.Fields("Result_Compil") = Array1(x, 30)
.Fields("Result_Safe") = Array1(x, 31)
.Fields("Result_Envi") = Array1(x, 32)
.Fields("Result_integrity") = Array1(x, 33)
.Fields("Result_SCE") = Array1(x, 34)
.Fields("Result_Financial") = Array1(x, 35)
.Fields("Result_Media") = Array1(x, 36)
.Fields("Final_Result") = Array1(x, 37)
.Fields("Manual_Result") = Array1(x, 38)
.Update
End With
Next
' Close database
Db1.Close
'Delete records feom the sheet
Plage.ClearContents
End Sub |
Partager