|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub TestClick1()
- Dim cnn, mydata$, mytable$, Sql$, Arr, Brr, i&, j&
- mydata = ThisWorkbook.Path & "\ADOTest.mdb"
- mytable = "plan"
-
- Set cnn = CreateObject("Adodb.Connection")
- With cnn
- .Provider = "microsoft.jet.oledb.4.0"
- .Open mydata
- End With
- Sql = "select * from " & mytable
- Arr = cnn.Execute(Sql).GetRows
- ReDim Brr(1 To 3, 0 To 3)
- For i = 1 To 3
- For j = 0 To 3
- Brr(i, j) = Arr(j, i)
- Next
- Next
- [a20].Resize(UBound(Brr), UBound(Brr, 2) + 1) = Brr
- cnn.Close
- Set cnn = Nothing
- End Sub
复制代码 |
|