在excel(A)中点按钮,自动把excel(B)的sheet1中【B2:E2,B3:E3】范围的值,拷贝到excel(C)中,VBA怎么写?

[复制链接]
查看11 | 回复4 | 2011-7-5 06:51:18 | 显示全部楼层 |阅读模式
现在有三个excel(A,B和C)
所有操作在A中进行,在A中点一个按钮,自动把excel(B)的sheet1中【B2:E2,B3:E3】范围的值,拷贝到excel(C)中,操作过程中,excel(A和B)不打开,怎么写这个VBA?
Dim app As New Application
Dim fromsheet, tosheet As Worksheet
Set fromsheet = app.Workbooks.Open("B.xls").Sheets("sheet1")
Set tosheet = app.Workbooks.Open("C.xls").Sheets("Sheet1")
Dim selectpart As String
selectpart = "B2:E2,B3:E3"
fromsheet.Range(selectpart).Select
Selection.Copy
tosheet.Activate
Range("A1").Select
ActiveSheet.Paste
app.Workbooks("B.xls").Close
app.Workbooks("C.xls").Save
app.Workbooks("C.xls").Close
这么写怎么不行呢?

回复

使用道具 举报

千问 | 2011-7-5 06:51:18 | 显示全部楼层
Wang the suspect's girlfriend fell in love four years to break, Wang angry Nanchang County man will kill his girlfriend at home. To avoid legal sanctions, he made both he and his girlfriend false sentimentalism, trying to disrupt the police investigation. However, the cunning of the fox eventually exposed the tail. gir...
回复

使用道具 举报

千问 | 2011-7-5 06:51:18 | 显示全部楼层
在B4,B8,B12中输入以下公式 =INDEX(A:A,ROW()/4 1) 左键,向下b4中引用就用$sheet1:e2 b8 中引用就是 sheet1:e3 b13 中引用就是...
回复

使用道具 举报

千问 | 2011-7-5 06:51:18 | 显示全部楼层
在B4,B8,B12中输入以下公式 =INDEX(A:A,ROW()/4 1) 左键,向下b4中引用就用$sheet1:e2 b8 中引用就是 sheet1:e3 b13 中引用就是...
回复

使用道具 举报

千问 | 2011-7-5 06:51:18 | 显示全部楼层
搞复杂了...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行