|
w_hb 发表于 2012-9-10 22:14
继续顶起,期待更好的解决方案中............ - Sub ts()
- Dim i&, j&, k&, ar, d As Object, dk, rng As Range, wb As Workbook
- Set d = CreateObject("Scripting.Dictionary")
- ar = [A6].CurrentRegion
- For i = 2 To UBound(ar)
- d(ar(i, 7)) = ""
- Next i
- dk = d.keys
- Set wb = Workbooks.Add(xlWBATWorksheet)
- For j = 0 To UBound(dk)
- If Len(dk(j)) > 0 Then
- ThisWorkbook.Sheets("Sheet1").Copy after:=wb.Sheets(wb.Sheets.Count)
- With ActiveSheet
- .Name = dk(j)
- .[C3] = dk(j)
- For k = 7 To UBound(ar) + 5
- If Len(.Cells(k, 7).Value) Then
- If .Cells(k, 7).Value <> dk(j) Then
- If rng Is Nothing Then
- Set rng = .Cells(k, 7)
- Else
- Set rng = Union(rng, .Cells(k, 7))
- End If
- End If
- End If
- Next k
- rng.EntireRow.Delete
- Set rng = Nothing
- .[A7] = 1
- .[A7].AutoFill Destination:=.[A7].Resize(.Cells(Rows.Count, 1).End(3).Row - 6, 1), Type:=xlFillSeries
- End With
- End If
- Next j
- Application.DisplayAlerts = False
- wb.Sheets(1).Delete
- Application.DisplayAlerts = True
- Set d = Nothing
- Set wb = Nothing
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|