|
像这种 你把标题行号引用为对话款形式就可以成这一类型的通用工具了多好 用时只需运行输入标题行的最末行号就ok了 再做一下小修改比如这样- Sub 多薄同名表重组为一薄多表()
- Dim d As Object, p$, f$, h&, sh As Worksheet, nm$, n As Name
- bm = ActiveSheet.Name
- btzmh = Val(Application.InputBox("请输入 标题最末行的行号:"))
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- p = ThisWorkbook.Path & ""
- f = Dir(p & "*.xls*")
- Application.DisplayAlerts = False
- Do While f <> ""
- If f <> ThisWorkbook.Name Then
- With Workbooks.Open(p & f)
- For Each sh In .Worksheets
- nm = sh.Name
- If Not d.exists(nm) Then
- d(nm) = ""
- sh.Copy after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
- Else
- With sh
- h = .[b65536].End(xlUp).Row - btzmh
- .UsedRange.Offset(btzmh).Resize(h).Copy ThisWorkbook.Sheets(nm).[b65536].End(xlUp).Offset(1, -1)
- End With
- End If
- Next
- .Close 0
- End With
- End If
- f = Dir
- Loop
- On Error Resume Next
- For Each n In ThisWorkbook.Names
- n.Delete
- Next
- Err.Clear
- Sheets(bm).Delete
- Set d = Nothing
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- MsgBox "提取完毕!"
- End Sub
复制代码 |
|