|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Public Sub huizong()
- Dim MyRow, Myrow1, MyCol, arr, wb, i%, brr, crr, unfile
- X: arr = Application.GetOpenFilename("表格文件,*.xls*", 1, "选取工作表", , True)
- If IsArray(arr) = False Then '当打开文件多选为:True时,用IsArray判断是否选择文件,当多选为False时,用arr<>false进行判断
- unfile = MsgBox("您未选中任何文件!" & Chr(10) & "按“确认”重新加载文件,或按“取消”退出", 1, "载入文件提示")
- If unfile <> vbCancel Then
- GoTo X '"按“确认”重新加载文件
- Else: Exit Sub '"按“取消”退出
- End If
- Else
- With ThisWorkbook.Worksheets("在职三定人员")
- .Range("a7:q60000").ClearContents
- MyRow = .Cells(Rows.Count, "b").End(xlUp).Row
- MyCol = 17
- End With
- For Each wb In arr
- Application.ScreenUpdating = False
- If wb <> ThisWorkbook.FullName Then '判断选择的工作表是否为汇总表,否则向下执行,如是则退出,进行下一循环
- Workbooks.Open (wb)
- Worksheets("在职三定人员").Activate
- With ActiveSheet
- Myrow1 = .Cells(Rows.Count, "b").End(xlUp).Row
- brr = .Range("a7:p" & Myrow1)
- crr = Mid(.[a1].Value, 1, 3)
- End With
- i = i + 1
- With ThisWorkbook.Worksheets("在职三定人员")
- .Cells(MyRow + 1, "a").Resize(Myrow1 - 6, 1) = crr
- .Cells(MyRow + 1, "b").Resize(Myrow1 - 6, MyCol - 1) = brr
- End With
- Set brr = Nothing
- ActiveWorkbook.Close (False)
- End If
- MyRow = MyRow + Myrow1 - 6
- Next
- End If
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|