1解決方案:將excel按照某一列拆分成多個文件
百度得:https://blog.csdn.net/ntotl/article/details/79141314
2遇到問題:解決vbe6ext.olb不能被加載 內存溢出 問題
百度得:http://www.udaxia.com/wtjd/13635.html
3問題原因:VBA文件位置不同
有的是:C:\Program Files (x86)\Common Files\microsoft shared\VBA
有的是:C:\Program Files \Common Files\microsoft shared\VBA
而我兩個位置都有VBA文件。所以我先把兩個地方的VBA文件復制一份(怕搞錯無法恢復),然后把兩個地方的VBA6、VBA7.1 都試了一篇,最后成功了。
4VB核心代碼:

Sub 保留表頭拆分數據為若干新工作簿() Dim arr, d As Object, k, t, i&, lc%, rng As Range, c% c = Application.InputBox("請輸入拆分列號", , 4, , , , , 1) If c = 0 Then Exit Sub Application.ScreenUpdating = False Application.DisplayAlerts = False arr = [a1].CurrentRegion lc = UBound(arr, 2) Set rng = [a1].Resize(, lc) Set d = CreateObject("scripting.dictionary") For i = 2 To UBound(arr) If Not d.Exists(arr(i, c)) Then Set d(arr(i, c)) = Cells(i, 1).Resize(1, lc) Else Set d(arr(i, c)) = Union(d(arr(i, c)), Cells(i, 1).Resize(1, lc)) End If Next k = d.Keys t = d.Items For i = 0 To d.Count - 1 With Workbooks.Add(xlWBATWorksheet) rng.Copy .Sheets(1).[a1] t(i).Copy .Sheets(1).[a2] .SaveAs Filename:=ThisWorkbook.Path & "\" & k(i) & ".xls" .Close End With Next Application.DisplayAlerts = True Application.ScreenUpdating = True MsgBox "完畢" End Sub