Sub ADO_INPUT() '将记录导入到excel中 Dim RS1 As Recordset Dim DB1 As Database Dim col As Integer Dim I As Integer 'On Error GoTo 1000 col = Sheet2.Range("A65535").End(xlUp).Row Set DB1 = OpenDatabase(ThisWorkbook.Path & "\" & "backdatabase.accdb ") Set RS1 = DB1.OpenRecordset(Name:="aa", Type:=dbOpenDynaset) dim m as integer For I = 7 To col With RS1 .AddNew for m = 1 to 17 '如果你的数据库中的数据跟excel都是按照顺序来的,则用一个循环足以! .fields(m)=sheet2.cells(i,m) next .Update End With Next I RS1.Close '1000: MsgBox "找不到符合条件的记录", 1 + 64, "系统提示" End Sub |
|
来自: POTATO1990 > 《我的图书馆》