如何用VBA新建一个EXCEL表,并将将另一个EXCEL表中的内容复制到这个新建的EXCEL表中
我想在我的计算程序运行完后,产生一个新表,并将表中的内容复制到这个新建的表中我在网上找到一段代码,我改了改,但只能新建一个表,并打开它,内容复制的代码不知如何写Sub新建...
我想在我的计算程序运行完后,产生一个新表,并将表中的内容复制到这个新建的表中
我在网上找到一段代码,我改了改,但只能新建一个表,并打开它,内容复制的代码不知如何写
Sub 新建()
Dim ExcelApplication As Variant
Set ExcelApplication = CreateObject("Excel.Application")
Dim TPath As String
TPath = ActiveWorkbook.Path
With ExcelApplication
.Workbooks.Add
.ActiveWorkbook.SaveAs Filename:=TPath & "\" & "新建表1" & ".xls"
.Quit
End With
Workbooks.Open TPath & "\" & "新建表1.xls"
End Sub
内容复制的代码
Workbooks("计算表").Worksheets("sheet1").UsedRange.Copy Workbooks("新建表1").Worksheets("sheet1").[a1]
可是不对,不知道该如何编写,有谁知道,先谢谢了! 展开
我在网上找到一段代码,我改了改,但只能新建一个表,并打开它,内容复制的代码不知如何写
Sub 新建()
Dim ExcelApplication As Variant
Set ExcelApplication = CreateObject("Excel.Application")
Dim TPath As String
TPath = ActiveWorkbook.Path
With ExcelApplication
.Workbooks.Add
.ActiveWorkbook.SaveAs Filename:=TPath & "\" & "新建表1" & ".xls"
.Quit
End With
Workbooks.Open TPath & "\" & "新建表1.xls"
End Sub
内容复制的代码
Workbooks("计算表").Worksheets("sheet1").UsedRange.Copy Workbooks("新建表1").Worksheets("sheet1").[a1]
可是不对,不知道该如何编写,有谁知道,先谢谢了! 展开
2个回答
展开全部
Sub 新建()
Dim excelApp, excelWB As Object
Dim savePath As String
Set excelApp = CreateObject("Excel.Application")
Set excelWB = excelApp.Workbooks.Add
excelApp.DisplayAlerts = False
savePath = ActiveWorkbook.Path & "\新建表1.xls"
excelWB.SaveAs savePath
excelApp.Quit
Workbooks.Open savePath
End Sub
内容复制:
Workbooks("计算表.xls").Worksheets("Sheet1"腔纳游).Copy Before:=Workbooks("新建表1.xls").Sheets(1)
把伍销“计算表”的Sheet1整个复制到“新茄穗建表1”中,为最前面一个Sheet,默认命名将是“Sheet1(2)”,楼主可以再重新命名Sheet就行了。
Dim excelApp, excelWB As Object
Dim savePath As String
Set excelApp = CreateObject("Excel.Application")
Set excelWB = excelApp.Workbooks.Add
excelApp.DisplayAlerts = False
savePath = ActiveWorkbook.Path & "\新建表1.xls"
excelWB.SaveAs savePath
excelApp.Quit
Workbooks.Open savePath
End Sub
内容复制:
Workbooks("计算表.xls").Worksheets("Sheet1"腔纳游).Copy Before:=Workbooks("新建表1.xls").Sheets(1)
把伍销“计算表”的Sheet1整个复制到“新茄穗建表1”中,为最前面一个Sheet,默认命名将是“Sheet1(2)”,楼主可以再重新命名Sheet就行了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询