|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub Macro1()
Dim MyFile, sh, wb As Workbook
Dim arr, i, ir
MyFile = Application.GetOpenFilename(fileFilter:="Excel文件(*.xls),*.xls", Title:="选择Excel文件")
If TypeName(MyFile) = "Boolean" Then Exit Sub
Cells.Clear
If MyFile = ThisWorkbook.FullName Then
MsgBox "不能选择本工作簿,请重新选择!", vbInformation
Exit Sub
End If
Set wb = GetObject(MyFile)
arr = Array("1", "2", "3", "4")
For i = 0 To UBound(arr)
Set sh = wb.Sheets(arr(i))
ir = ThisWorkbook.ActiveSheet.[a65536].End(xlUp).Row
sh.UsedRange.Copy ThisWorkbook.ActiveSheet.Range("a" & ir + 1)
Next i
wb.Close True
MsgBox "ok"
End Sub
|
评分
-
1
查看全部评分
-
|