|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub ADO_有字段名()
Dim myb As Object: Dim s As Integer: Dim mycnt As Integer: Dim x As Integer
[a1:Z65536] = Empty
Set mycn = CreateObject("adodb.connection")
Set myrs = CreateObject("adodb.recordset")
mycn.Open "dsn=excel files;hdr=yes;dbq=" & ThisWorkbook.FullName
Sql = "select * from[Report 1$A4:R] "
myrs.Open Sql, mycn, 1, 1
a = myrs.RecordCount
For Each Field In myrs.Fields
aa = Field.Name
[A1].Offset(0, i) = Field.Name
i = i + 1
Next
Range("a2").CopyFromRecordset myrs
End Sub |
评分
-
1
查看全部评分
-
|