|
Sub limonet()
Dim i%, j%, k%, Arr As Variant, Cn As Object, StrSQL$
Set Cn = CreateObject("Adodb.Connection")
Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 12.0;imex=1';Data Source=" & ThisWorkbook.FullName
StrSQL = "Select [电缆编号]&'¥'&[起点]&'¥'&[终点]&'¥'&[电缆规格] From [分支电缆$B2:E]"
Arr = Cn.Execute(StrSQL).getrows
For i = 2 To UBound(Arr, 2) + 30 Step 5
For j = 2 To 11 Step 3
Range("M2:N5").Copy Cells(i, j - 1)
Cells(i, j).Resize(4) = Application.Transpose(Split(Arr(0, k), "¥"))
k = k + 1
Next j
Next i
End Sub
|
|