df1
( Speed 1.0 0 201205291004 11.230000000 -97.210000000 -1 Art )
0 0
1 0.75
2 1.10
3 1.52
4 1.59
df2
0 33.55 45
1 61.37 62
2 71.52 78
我正在尝试复制df1
标头并插入df2
作为标头。它可以吗?
请注意,df1
有一列,df2
有两列。
输出应为:
df2
( Speed 1.0 0 201205291004 11.230000000 -97.210000000 -1 Art )
0 33.55 45
1 61.37 62
2 71.52 78
答案 0 :(得分:1)
这应该有效:
Sub ExportRangetoFile()
'Update 20150628
Dim Rng As Range
Dim WorkRng As Range
Dim xFile As Variant
Dim xFileString As String
On Error Resume Next
xTitleId = "KutoolsforExcel"
lastrow= workbook.sheet1.range("A "& rows.count & "").end(xlup).row
Set WorkRng = workbook.sheet1.range("A1:D " & lastrow & "")
'Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address,
Type:=8)
Application.ActiveSheet.Copy
Application.ActiveSheet.Cells.Clear
WorkRng.Copy Application.ActiveSheet.Range("A1")
Set xFile = CreateObject("Scripting.FileSystemObject")
xFileString = "somename"& format(now(),"ddmmyyyy")
'Application.GetSaveAsFilename("", filefilter:="Comma Separated
Text (*.CSV), *.CSV")
Application.ActiveWorkbook.SaveAs Filename:=xFileString, FileFormat:=xlCSV,
CreateBackup:=False
End Sub