|
下面是我从论坛找到的一个例子 ,想学习一下 但是代码不知是啥意思 ,只好麻烦各位了!请解释行后面带“?”号的代码
Sub Macro1()
Dim conn As Object, sql$
Set conn = CreateObject("adodb.connection") ‘’ ??这是个什么对象
conn.Open "provider=microsoft.jet.oledb.4.0;extended properties='excel 8.0;imex=1;HDR=no';data source=" & ThisWorkbook.Path & "\登记查询1.xls" ’ ??请解释
sql = "select f1,f5,f6,f7,f8,f9,f11,f4 from [数据库$A2:K65536] where f11 is not null " ‘??这个在后面是怎么用的,怎么运行的
Application.ScreenUpdating = False
ActiveSheet.UsedRange.Offset(1, 0).ClearContents
Range("a2").CopyFromRecordset conn.Execute(sql) ’ ??这里怎么运行
conn.Close
Set conn = Nothing
Range("G2:H" & Range("G65536").End(xlUp).Row).Cut Range("H2")
Application.ScreenUpdating = True
End Sub
|
|