学习爱歌学习的ADO方法做了个用ADO处理你这个问题的. 那些文件目录和工作表名称没有使用变量. 你可以自己改下. 多谢爱歌学习的帖子. Sub bb() Dim CNN As New ADODB.Connection Dim RST As New ADODB.Recordset Dim arr() As Variant Dim iRow As Integer Dim iCol As Integer With CNN .ConnectionString = "provider=microsoft.jet.oledb.4.0;" & _ "extended properties='Excel 8.0;hdr=no';" & _ "data source=C:\temp\表格01.xls" .Open End With RST.Open "select * from [情况表$A1:H12]", CNN, 1, 3 iRow = RST.RecordCount iCol = RST.Fields.Count ReDim arr(1 To iRow, 1 To iCol) As Variant For i = 1 To iRow For j = 1 To iCol arr(i, j) = RST.Fields(j - 1).Value Next j RST.MoveNext Next i 'RST.Update RST.Close CNN.Close With CNN .ConnectionString = "provider=microsoft.jet.oledb.4.0;" & _ "extended properties='Excel 8.0;hdr=no';" & _ "data source=C:\temp\临时xls" .Open For i = 1 To iRow For j = 1 To iCol strt = "update [报表$" & Chr(97 + j) & (i + 1) & ":" & Chr(97 + j) & (i + 1) & "] set f1='" & arr(i, j) & "'" .Execute strt Next j Next i End With
qxR2G7VY.zip
(9.18 KB, 下载次数: 880)
|