|
- Sub cdsr()
- Dim arr, brr(), i&, d As Object, ws As Worksheet, dd, j%, k&
- arr = Sheet1.[a1].CurrentRegion
- Set d = CreateObject("scripting.dictionary")
- ReDim brr(1 To UBound(arr), 1 To 7)
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- For Each ws In Worksheets
- If ws.Index > 1 Then
- ws.Delete
- End If
- Next
- For i = 2 To UBound(arr)
- d(arr(i, 5)) = ""
- Next
- For Each dd In d.keys
- Set ws = Worksheets.Add(after:=Worksheets(Worksheets.Count))
- ws.Name = dd
- For i = 2 To UBound(arr)
- If arr(i, 5) = dd Then
- k = k + 1
- For j = 1 To 7
- brr(k, j) = arr(i, j)
- Next
- End If
- Next
- ws.Range("a1:g1") = Array("字段1", "字段2", "字段3", "字段4", "字段5", "字段6", "字段7")
- ws.Range("a2").Resize(k, 7) = brr
- k = 0
- Next
- Sheet1.Select
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|