|
写了个拆分,模板套打那个没空研究,仅供参考:Sub 拆分数据() Dim i As Long Dim str, str1 Application.DisplayAlerts = False If Sheets.Count > 1 Then For Each sht1 In Sheets If sht1.Name <> "税表" And sht1.Name <> "数据源" Then sht1.Delete End If Next End If Application.DisplayAlerts = True arr = Sheets("数据源").Range("a1").CurrentRegion Set d = CreateObject("scripting.dictionary") For i = 2 To UBound(arr) If d.exists(arr(i, 5)) Then Set d(arr(i, 5)) = Union(d(arr(i, 5)), Rows(i)) Else Set d(arr(i, 5)) = Union(Rows(1), Rows(i)) End If Next i For str = 0 To d.Count - 1 str1 = Trim(d.keys()(str)) Worksheets.Add.Name = str1 d.items()(str).Copy Sheets(str1).Range("a1") Next str Sheets("数据源").Activate End Sub |
|