|
请高手帮忙看看为什么执行完毕后多了一行?不知道哪里有问题!- Sub 转口临时表()
- Application.ScreenUpdating = False
- Sheets("转口临时表").UsedRange.Clear '清空临时表
-
- Dim Conn As Object, Rst As Object
- Dim strConn As String, strSQL As String
- Dim i As Integer, PathStr As String
- Dim StarTime As Date, EndTime As Date, BiZhong As String
- Set Conn = CreateObject("ADODB.Connection")
- Set Rst = CreateObject("ADODB.Recordset")
- PathStr = ThisWorkbook.FullName
- Select Case Application.Version * 1
- Case Is <= 11
- strConn = "Provider=Microsoft.Jet.Oledb.4.0;Extended Properties=excel 8.0;Data source=" & PathStr
- Case Is >= 12
- strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & PathStr & ";Extended Properties=""Excel 12.0;HDR=YES"";"""
- End Select
- strSQL = "Select distinct PartNo,sum(Qty) as Qty,price*1.05 as NewPrice,0 as Total,Price,0 as Customer,DateCode,SP_No,CPN From [临时表$] group by PartNo,DateCode,SP_No,CPN,Price order by PartNo,DateCode "
- Conn.Open strConn
- Set Rst = Conn.Execute(strSQL)
- With Sheets("转口临时表")
- For i = 0 To Rst.Fields.Count - 1
- .Cells(1, i + 1) = Rst.Fields(i).Name
- Next i
- .Range("A2").CopyFromRecordset Rst
- End With
- Rst.Close
- Conn.Close
- Set Conn = Nothing
- Set Rst = Nothing
-
- 'Sheets("常规入库单").Select
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|