vba中关于读取EXCEL文件
Dim filepath As String
Dim vtSql As String
Dim rstRecordset As ADODB.recordset
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim userCount As Integer
Dim excuteCount As Integer
filepath = ThisWorkbook.FullName
Set xlApp = CreateObject("Excel.Application")
Set xlBook = ThisWorkbook
Set xlsheet = xlBook.Worksheets(2)
xlApp.Visible = False
xlsheet.Activate
画面清空处理
xlsheet.Cells.Clear
Worksheets("Sheet3").Range("A1:U5").Copy _
Destination:=Worksheets("Sheet2").Range("A1")
变量实例化
Set cnn = New ADODB.Connection
Set rstRecordset = New ADODB.recordset
声明SQL
vtSql = ""
通过SQL获得结果集
Set rstRecordset = tools.conn(filepath, "1", vtSql)
结果集不为空时候
Do While Not rstRecordset.EOF
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载