更新时间:2023-01-30 20:08:44
这样使用数组, (假设您的数据具有与感兴趣的列相同的从D到P的列长度)
Somewthing like this uses array's and is very efficient (it assumes your data has the same column length from D to P for the columns of interest)
Sub csvfile()
Dim fs As Object
Dim a As Object
Dim lngRow As Long
Dim X
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\temp\" & Environ("username") & ".csv", True)
X = Range([d4], Cells(Rows.Count, "P").End(xlUp)).Value2
For lngRow = 1 To UBound(X)
a.writeline X(lngRow, 1) & "," & X(lngRow, 3) & X(lngRow, 4) & ",,," & X(lngRow, 8) & "," & X(lngRow, 9) & "," & X(lngRow, 11) & ",," & X(lngRow, 13)
Next
a.Close
End Sub