excel如何vba实现从另一个工作簿复制选定区域的数据到当前工作簿

2024-12-03 13:49:07
推荐回答(1个)
回答1:

运行之后,选择那个“文件2”,点确定,就把“文件2”里"sheet3"的A1:L1000复制到运行文档“sheet1”的B2:M1001了~
附件文档的模块1里,按alt+f11打开编辑器
http://pan.baidu.com/s/1c2kxQ9q
Sub a()
Dim a
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.InitialFileName = ThisWorkbook.Path
If .Show = -1 Then
Set a = Workbooks.Open(.SelectedItems(1))
a.Sheets("sheet3").AutoFilterMode = False
a.Sheets("sheet3").Range("A1:L1000").Copy ThisWorkbook.Sheets("sheet1").Range("B2")
a.Close False
End If
End With
End Sub