Pessoal fiz o seguinte ... mais não esta rodando .. tenho o excel 2010 .. o que estaria de errado?
Sub AtualizarBD()
Dim cnt As ADODB.Connection, _
rst As ADODB.Recordset, _
dbPath As String, _
tblName As String, _
colHead As String, _
rcdDetail As String, _
sConnect As String
On Error Resume Next
Set cnt = New ADODB.Connection
Set rst = New ADODB.Recordset
dbPath = "C:Usersnatalia.oliveira.CONNECTCOMDesktopplanilhas novasPLANILHA PEÇAS.accdb"
tblName = "estoque_vivo_novo"
tblCol = "saldo_atualizado"
sConnect = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & dbPath & "';"
cnt.Open sConnect
Dim i, j, k As Integer
i = 7 ' linha
j = 3 ' coluna do id
k = 20 ' coluna do saldo atualizado
Do
strSQL = "UPDATE " & tblName & " "
strSQL = strSQL & "SET " & tblCol & "=" & Worksheets("estoque").Cells(i, k).Value & " "
strSQL = strSQL & "WHERE "
strSQL = strSQL & "ID=" & Worksheets("estoque").Cells(i, j).Value
Set rst = cnt.Execute(strSQL)
i = i + 1
Loop Until Worksheets("estoque").Cells(i, j).Value = ""
'MsgBox strSQL, vbOKOnly, ""
cnt.Close
Set rst = Nothing
Set cnt = Nothing
On Error GoTo 0
End Sub
Postado : 16/07/2012 11:36 am