|
- Sub test1() '凑一下
- Dim Conn As Object, SQL As String, strConn As String
- 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
- Set Conn = CreateObject("ADODB.Connection")
- Conn.Open strConn & ThisWorkbook.FullName
- SQL = "SELECT LEFT(物料编码,INSTR(物料编码,'#')-1),MID(物料编码,INSTR(物料编码,'#')+1) FROM [Sheet1$]"
- With Range("C1")
- .CurrentRegion.ClearContents
- .Resize(, 2) = Split("名称 型号")
- .Offset(1).CopyFromRecordset Conn.Execute(SQL)
- End With
- Conn.Close
- Set Conn = Nothing
- Beep
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|