|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
楼主可以试一下,行不行。
Sub up()
Dim cn As Object, sql As String, arr, i%, j%, m%, t%
Set cn = CreateObject("ADODB.Connection")
cn.Mode = adModeShareDenyNone
arr = [a1].CurrentRegion
For i = 2 To UBound(arr)
For j = 9 To 11
sql = sql & arr(1, j) & "='" & arr(i, j) & "',"
Next
sql = Left(sql, Len(sql) - 1)
sql = "update 制令单 SET " & sql & " WHERE 制令单号='" & arr(i, 1) & "'"
cn.Open "provider=microsoft.ace.oledb.12.0;data source=" & ThisWorkbook.Path & "\制令单总表.accdb"
cn.Execute sql, m, 1
t = m + t
cn.Close
sql = ""
Next
Set cn = Nothing
MsgBox "更新" & t & "条数据"
End Sub |
|