|
- Sub ek_sky()
- Dim a As Variant, r1 As Long, c1 As Byte, b() As Variant
- Dim d As Object, j As Long
- Set d = CreateObject("scripting.dictionary")
- With Sheets("sheet1")
- a = .Range("A1:E8").Value
- End With
- For r1 = 1 To UBound(a)
- For c1 = 1 To UBound(a, 2)
- If a(r1, c1) <> "" Then
- If Not d.exists(a(r1, c1)) Then
- j = j + 1
- d.Add a(r1, c1), j
- ReDim Preserve b(1 To 1, 1 To j)
- b(1, j) = a(r1, c1)
- End If
- End If
- Next c1
- Next r1
- With Sheets("sheet2")
- .Range("A:A").ClearContents
- .Range("A1").Resize(j) = WorksheetFunction.Transpose(b)
- End With
- Set a = Nothing: Set d = Nothing
- End Sub
复制代码 |
|