|
Sub limonet()
Dim Cn As Object, StrSQL$, Arr As Variant, Rst As Object, Rst1 As Object
Set Cn = CreateObject("Adodb.Connection")
Set Rst = CreateObject("adodb.recordset")
Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 12.0;Hdr=No';Data Source=" & ThisWorkbook.FullName
StrSQL = "Select * From [Sheet1$A3:R]"
Rst.Open StrSQL, Cn, 1, 3
Set Rst1 = Cn.Execute(StrSQL)
ReDim Arr(1 To Rst.RecordCount, 1 To 2)
For i = 1 To Rst.RecordCount
Arr(i, 1) = Join(Application.Transpose(Rst.GetRows(1)), "+")
Arr(i, 2) = "\" & Join(Application.Transpose(Rst1.GetRows(1, , Array("F2", "F3", "F5"))), "+") & ".xlsm"
Next i
Range("A4:S99").Clear
For i = 1 To UBound(Arr)
Range("A3").Resize(1, 18) = Split(Arr(i, 1), "+")
ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & Arr(i, 2)
Next i
End Sub |
|