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
| Dim Cn As ADODB.connection
Dim Cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim CheminBase As String, strCn As String, strInsert As String, strUpdate As String
Dim r As Long
ActiveWorkbook.Sheets("Input Sheet").Select
CheminBase = "D:\VBA Projets\Projet 2 outil de valorisation\2017_ProjectAppleDataBase.accdb"
Set Cn = New ADODB.connection
strCn = "Provider=Microsoft.ACE.OLEDB.12.0; " & "Data Source=" & CheminBase & ";"
Cn.Open strCn
Set rs = New ADODB.Recordset
rs.Open "SELECT parameterValue FROM inputParametersSaved", Cn, adOpenKeyset, adLockOptimistic
Range("B4").Select
derniere_ligne = Range("B29").End(xlDown).Row
If rs.EOF = True Then
For I = 1 To derniere_ligne - 1
strInsert = "INSERT INTO parametersValue (Revenues,Income,equity) VALUES ('" & Range("B4").Offset(I, 0).Value & "', #" & Range("B5").Offset(I, 1).Value & "#, '" & Range("B6").Offset(I, 2).Value & "')"
Cn.Execute strInsert
Next I
End If
' Fermeture recordset et connection
rs.Close
Set rs = Nothing
Cn.Close
Set Cn = Nothing
End Sub |
Partager