안녕하세요?
말씀주신 내용과 다른내용까지 좀더 면밀히 살펴보니 C열의 데이터중 ?때문에 count에 오류가 생기는것을 확인했습니다.
그래서 '?'를 모두 '_'로 수정해서 처리했습니다.
꼼꼼하게 한번에 봤어야 하는데 미안합니다.
아래는 첨부파일에 사용된 코드입니다.
Option Explicit
Sub Test()
Dim i As Long
Dim S_i As Long
Dim n As Long
Dim Spl As Variant
Dim Rng As Range
Dim Rng2 As Range
Dim Opt As Variant
Application.ScreenUpdating = False
Sheet3.Range("a2:f1048576").Clear
With Sheet1
For i = 1 To .Cells(Rows.Count, "c").End(xlUp).Row
If Len(.Cells(i, "c")) = 0 Then
Else
Spl = Split(.Cells(i, "c"), ",")
Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(UBound(Spl, 1) + 1).Value = _
Application.Transpose(Spl)
End If
Next i
End With
With Sheet3
.Columns("a").Replace "~?", "_", xlPart, xlByRows, False, False, False
Set Rng = .Range(.Range("a2"), .Cells(Rows.Count, 1).End(xlUp))
.Columns("A").Copy .Columns("e")
.Columns("e").RemoveDuplicates Columns:=1, Header:=xlNo
For i = 2 To .Cells(Rows.Count, "e").End(xlUp).Row
.Cells(i, "f") = Application.WorksheetFunction.CountIf(Rng, .Cells(i, "e"))
Next i
Set Rng2 = .Range(.Range("f2"), .Range("f1048576").End(xlUp))
If MsgBox("오름차순 정렬을 원하시면 Yes, 내림차순은 No를 클릭하세요.", _
vbInformation + vbYesNo, "Option") = vbYes Then
Opt = xlAscending
Else
Opt = xlDescending
End If
.Sort.SortFields.Clear
.Sort.SortFields.Add Rng2, xlSortOnValues, Opt, xlSortNormal
.Sort.SetRange .Range("e1").CurrentRegion
.Sort.Header = xlYes
.Sort.Apply
.Range("e1").CurrentRegion.Borders.Weight = xlThin
Rng2.NumberFormatLocal = "#,##0_-"
.Select
End With
Application.ScreenUpdating = True
End Sub
자세한 내용은 첨부파일을 참고로...
그럼 잘 해결되시길... ^^*
======================================================================================
첨부파일
======================================================================================