Office中国论坛/Access中国论坛
标题:
提取整列数据
[打印本页]
作者:
156595311
时间:
2013-7-24 07:15
标题:
提取整列数据
提取整列数据,只要其中指定列,不是整行提取。
作者:
156595311
时间:
2013-7-24 19:08
Sub 数据提取()
Dim cnn As Object, cat As Object
Dim i As Integer
Dim Mypath As String, Myfile As String
Dim sql As String
Dim tb As Object
Mypath = ThisWorkbook.Path & ""
Myfile = Dir(Mypath & "*.xls")
ActiveSheet.UsedRange.Offset(1).ClearContents
Set cnn = CreateObject("adodb.connection")
Set cat = CreateObject("ADOX.Catalog")
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" & Mypath & Myfile
Do While Myfile <> ""
If Myfile <> ThisWorkbook.Name Then
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0;HDR=No';Data Source=" & Mypath & Myfile
For Each tb In cat.tables
If tb.Type = "TABLE" Then
If tb.Name = "Sheet2$" Then
sql = "select 工号,收入 from[Excel 8.0;Database=" & Mypath & Myfile & "].[" & tb.Name & "a1:o65536]"
[a65536].End(3).Offset(1).CopyFromRecordset cnn.Execute(sql)
End If
End If
Next
End If
Myfile = Dir()
Loop
Set cat = Nothing
cnn.Close
Set cnn = Nothing
End Sub
复制代码
提取得不全的。怎么改好?
作者:
156595311
时间:
2013-7-25 22:43
怎么没人理的?要收钱吗?
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3