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
|
Sub update_tot()
Dim rs As Object
Dim strSQL As String
Dim strConnection As String
Set cn = CreateObject("ADODB.Connection")
strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & "\\chemin\madb.acdb"
der_li = der_ligne_feuille("a updater", "A")
Dim Range_Update As Range
Set Range_Update = Sheets("a updater").Range("A2:A" & (der_li - 1))
cn.Open strConnection
For Each cellule In Range_Update
Id_val = Sheets("a updater").Cells(cellule.Row, 1).Value
Entete = Sheets("a updater").Cells(cellule.Row, 2).Value
Val_champs = Sheets("a updater").Cells(cellule.Row, 3).Value
strSQL = "UPDATE Table SET [" & Entete & "] = '" & Val_champs & "' WHERE ID = " & Id_val
Sheets("a updater").Cells(cellule.Row, 8).Value = "UPDATE Table SET [" & Entete & "] = '" & Val_champs & "' WHERE ID = " & Id_val
Set rs = cn.Execute(strSQL)
rs.Close
Set rs = Nothing
Next cellule
cn.Close
Set cn = Nothing
End Sub |
Partager