- Public Sub format1()
- Dim ar, br(), i, j, c
- Dim d As Object
- Set d = CreateObject("Scripting.Dictionary")
- ar = ActiveSheet.UsedRange
- ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
- For i = 1 To UBound(ar)
- For j = 1 To UBound(ar, 2)
- If ar(i, j) <> "" And Not d.exists(ar(i, j)) Then d(ar(i, j)) = ""
- Next
- Next
- For i = 1 To UBound(ar)
- For j = 1 To UBound(ar, 2)
- If ar(i, j) <> "" And d.exists(ar(i, j)) Then
- c = Application.Match(ar(i, j), d.keys, 0)
- br(i, c) = ar(i, j)
- End If
- Next
- Next
- [i1].Resize(UBound(ar), UBound(ar, 2)) = br
- End Sub
复制代码
|