- 帖子
- 4
- 主題
- 2
- 精華
- 0
- 積分
- 6
- 點名
- 0
- 作業系統
- Windows7
- 軟體版本
- OFFICE2010
- 閱讀權限
- 10
- 性別
- 女
- 註冊時間
- 2012-12-21
- 最後登錄
- 2012-12-25
|
3#
發表於 2012-12-21 23:21
| 只看該作者
太感謝了,真的可以了耶!
可是我加了where 以後又不行了。主要是想將itm_no這個欄位不為空的才copy到Cells(1, 1).
會出現 error "參數太少,預期個數1"
Sub get_data_with_sql()
Set rs = CreateObject("adodb.recordset")
rs.Open "select * from [大大1217標籤$L2:V39] where itm_no is not null", "Driver={Microsoft Excel Driver (*.xls)};dbq=C:\Users\dsc\Documents\大大高中1217.xls"
Cells(1, 1).CopyFromRecordset (rs)
End Sub |
|