我想将数据从excel复制到。以下是我想要复制数据的方式。例如,我想将D4
excel 单元格中的数据复制到A4
csv中。
"Excel ---> CSV
"D4-->A4
"F4&all excluding the first character in G4-->B4
"K4-->E4
"L4-->F4
"N4-->G4
"P4-->I4
下面是我的代码。G4
它根据我的需要创建和填充数据,只是在复制到B4
in时不会删除 in 的第一个字符csv
。有人可以告诉我如何更改我的代码来实现这一点。
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) - 15
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