Sub Transferdonnées()
' exports data from the active worksheet to a table in an Access database
Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long, deletevalue As String
Dim strSQL As String
Dim cmd As ADODB.Command
Sheets("Données").Select
' connect to the Access database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=C:\Data\Données.accdb;Persist Security Info=False"
' open a recordset
Set rs = New ADODB.Recordset
rs.Open "T_Data", cn, adOpenKeyset, adLockOptimistic, adCmdTable
' all records in a table
r = 2 ' the start row in the worksheet
Do While Len(Range("A" & r).Formula) > 0
' repeat until first empty cell in column A
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("Année") = Range("A" & r).Value
.Fields("Mois") = Range("B" & r).Value
.Fields("Nom") = Range("C" & r).Value
.Fields("Prénom") = Range("D" & r).Value
' add more fields if necessary...
.Update ' stores the new record
End With
r = r + 1 ' next row
Loop
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub