请问如何用VBA将一个EXCEL文件中的数据复制到别一个EXCEL文件相同的位置?
4个回答
展开全部
Sub Work_copy()
Dim a As Range
Dim i As Long
Dim xls1 As Worksheet
Dim xls2 As Worksheet
Set xl1 = Workbooks("源文件").Worksheets("源工作表")
i = xl1.Index '返回源工作表的索引号
Set xl2 = Workbooks("目标文件").Worksheets(i)
a = Application.InputBox("选择要复制的单元格区域")
b = a.Address '返回复制源单元格地址
xl1.Range(b).Copy xl2.Range(b) '完成COPY
Set xl1 = Nothing '释放变量
Set xl2 = Nothing
End Sub
Dim a As Range
Dim i As Long
Dim xls1 As Worksheet
Dim xls2 As Worksheet
Set xl1 = Workbooks("源文件").Worksheets("源工作表")
i = xl1.Index '返回源工作表的索引号
Set xl2 = Workbooks("目标文件").Worksheets(i)
a = Application.InputBox("选择要复制的单元格区域")
b = a.Address '返回复制源单元格地址
xl1.Range(b).Copy xl2.Range(b) '完成COPY
Set xl1 = Nothing '释放变量
Set xl2 = Nothing
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sub aaa()
dim sh1 as worksheet
dim sh2 as worksheet
set sh1 = workbooks("1.xls").sheets(1)
set sh2 = workbooks("2.xls").sheets(1)
sh1.range(sh1.[a1], sh1.range("a1").end(xldown)).copy sh2.[a1]
sh1.range(sh1.[a65536].end(xlup), sh1.[a65536].end(xlup).end(xlup)).copy sh2.[b1]
end sub随便放哪个工作簿吧。但是,两个工作簿都要打开。当然你也可以加上打开工作簿的代码。
dim sh1 as worksheet
dim sh2 as worksheet
set sh1 = workbooks("1.xls").sheets(1)
set sh2 = workbooks("2.xls").sheets(1)
sh1.range(sh1.[a1], sh1.range("a1").end(xldown)).copy sh2.[a1]
sh1.range(sh1.[a65536].end(xlup), sh1.[a65536].end(xlup).end(xlup)).copy sh2.[b1]
end sub随便放哪个工作簿吧。但是,两个工作簿都要打开。当然你也可以加上打开工作簿的代码。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sheet1的区域A1:C3拷贝到sheet2的区域A1:C3
sheet1.range("A1:C3").copy sheet2.range("A1:C3")
sheet1.range("A1:C3").copy sheet2.range("A1:C3")
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Explicit
Dim currentBookName As String
Dim currentSheetName As String
Dim gaoLu(6, 1, 1) As String
Sub 自动生成标签日期的日报()
currentBookName = ThisWorkbook.Name
currentSheetName = ThisWorkbook.ActiveSheet.Name
gaoLu(0, 0, 0) =
Dim currentBookName As String
Dim currentSheetName As String
Dim gaoLu(6, 1, 1) As String
Sub 自动生成标签日期的日报()
currentBookName = ThisWorkbook.Name
currentSheetName = ThisWorkbook.ActiveSheet.Name
gaoLu(0, 0, 0) =
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |