답변:
다음과 같이 해보십시오.
Sub Garlic()
Dim cl As Collection, sh1 As Worksheet, sh2 As Worksheet
Dim r As Range, K As Long, v As Variant, i As Long
Set cl = New Collection
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Sheet2")
K = 1
On Error Resume Next
For Each r In sh1.UsedRange
v = r.Value
If v <> "" Then
cl.Add v, CStr(v)
End If
Next r
On Error GoTo 0
For i = 1 To cl.Count
sh2.Cells(K, 1).Value = cl.Item(i)
K = K + 1
Next i
sh2.Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub