VBA 如何把计算结果 输出在两给一个excel表中, 挺急的,在线等,求高手请教
我之前在VBA中计算出来的已附值了的i,j,k怎么才能让这些值显示在别的excel表里(比如说,放在桌面上的book1中)挺急的,在线等,求高手请教就比如说,前面通过加减...
我之前在VBA中计算出来的已附值了的i, j,k 怎么才能让这些值显示在别的excel表里(比如说,放在桌面上的book1中)
挺急的,在线等,求高手请教
就比如说,前面通过加减乘除的VBA求得i,j,k,现在要输出在另外一个excel表中。求这段VBA的程序详细的编写!!!!! 真的老急的。。。。试了很多都出error 展开
挺急的,在线等,求高手请教
就比如说,前面通过加减乘除的VBA求得i,j,k,现在要输出在另外一个excel表中。求这段VBA的程序详细的编写!!!!! 真的老急的。。。。试了很多都出error 展开
1个回答
展开全部
Dim MyExcel As New Excel.Application
MyExcel.Workbooks.Add \'新建excel文档
\'MyExcel.Workbooks.Open (App.Path & "\test.xls") \'打开现有文档
MyExcel.Visible = True
\'添加边框
MyExcel.Range("A1", "C3").Borders.LineStyle = 1
MyExcel.Range("A1", "C3").Borders.Color = RGB(255, 0, 0)
\'合并单元格
MyExcel.Range("A1", "A3").Select \'选择
MyExcel.Selection.Merge \'合并
MyExcel.Range("b2", "c2").Select
MyExcel.Selection.Merge \'合并
\'写入文字
MyExcel.Cells(1, 1) = "测试"
MyExcel.Cells(1, 2) = "测试1"
MyExcel.Cells(1, 3) = "测试2"
MyExcel.Cells(2, 2) = "测试3"
MyExcel.Cells(3, 2) = "测试4"
MyExcel.Cells(3, 3) = "测试5"
\'设置格式
MyExcel.Range("a1", "c3").Font.Color = RGB(0, 0, 255) \'颜色
MyExcel.Range("a1", "c3").Font.Name = "宋体" \'字体
MyExcel.Range("a1", "c3").HorizontalAlignment = xlCenter \'水平居中
MyExcel.Range("a1", "c3").VerticalAlignment = xlCenter \'竖直居中
\'\'\'\'
MyExcel.Worksheets(2).Cells(1, 1) = "测试二"
MyExcel.Worksheets(3).Cells(1, 1) = "测试三"
MyExcel.ActiveWorkbook.SaveAs App.Path & "\test.xls"\'另存为
\'MyExcel.ActiveWorkbook.Save\'直接保存
MyExcel.Workbooks.Close \'关闭文档
myExcel.Quit\'退出excel程序
MyExcel.Workbooks.Add \'新建excel文档
\'MyExcel.Workbooks.Open (App.Path & "\test.xls") \'打开现有文档
MyExcel.Visible = True
\'添加边框
MyExcel.Range("A1", "C3").Borders.LineStyle = 1
MyExcel.Range("A1", "C3").Borders.Color = RGB(255, 0, 0)
\'合并单元格
MyExcel.Range("A1", "A3").Select \'选择
MyExcel.Selection.Merge \'合并
MyExcel.Range("b2", "c2").Select
MyExcel.Selection.Merge \'合并
\'写入文字
MyExcel.Cells(1, 1) = "测试"
MyExcel.Cells(1, 2) = "测试1"
MyExcel.Cells(1, 3) = "测试2"
MyExcel.Cells(2, 2) = "测试3"
MyExcel.Cells(3, 2) = "测试4"
MyExcel.Cells(3, 3) = "测试5"
\'设置格式
MyExcel.Range("a1", "c3").Font.Color = RGB(0, 0, 255) \'颜色
MyExcel.Range("a1", "c3").Font.Name = "宋体" \'字体
MyExcel.Range("a1", "c3").HorizontalAlignment = xlCenter \'水平居中
MyExcel.Range("a1", "c3").VerticalAlignment = xlCenter \'竖直居中
\'\'\'\'
MyExcel.Worksheets(2).Cells(1, 1) = "测试二"
MyExcel.Worksheets(3).Cells(1, 1) = "测试三"
MyExcel.ActiveWorkbook.SaveAs App.Path & "\test.xls"\'另存为
\'MyExcel.ActiveWorkbook.Save\'直接保存
MyExcel.Workbooks.Close \'关闭文档
myExcel.Quit\'退出excel程序
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询