|
Sub qs()
Dim conn
Dim rs
Dim strConn As String, SQL As String
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
If Application.Version < 12 Then
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source="
Else
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0;Data Source="
End If
conn.Open strConn & ThisWorkbook.FullName
SQL = "select * from [电子锯开料单$a3:n] order by 板件名称 desc"
rs.Open SQL, conn, 1, 2
With Sheet2
.Range("A4").Resize(10000, 14).ClearComments
.Range("A4").CopyFromRecordset rs
.Cells.EntireColumn.AutoFit
End With
Beep
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
End Sub |
评分
-
1
查看全部评分
-
|