Bạn có thể cho danh sách số thứ tự 35 cột đạt yêu cầu hay không, vì chạy thử thấy có 33 cột đạt yêu cầu. Không biết lệch chỗ nào
mình dùng code của bạn
Let'GâuGâu ra 35 cột, và dùng code của bạn và thay đổi 1 chút cũng ra 35 cột
[TABLE="width: 814"]
[TR]
[TD="class: xl65, width: 26"]1[/TD]
[TD="class: xl65, width: 23"]2[/TD]
[TD="class: xl65, width: 23"]3[/TD]
[TD="class: xl65, width: 23"]4[/TD]
[TD="class: xl65, width: 23"]5[/TD]
[TD="class: xl65, width: 23"]6[/TD]
[TD="class: xl65, width: 23"]7[/TD]
[TD="class: xl65, width: 23"]8[/TD]
[TD="class: xl65, width: 23"]9[/TD]
[TD="class: xl65, width: 23"]10[/TD]
[TD="class: xl65, width: 28"]20[/TD]
[TD="class: xl65, width: 23"]30[/TD]
[TD="class: xl65, width: 23"]40[/TD]
[TD="class: xl65, width: 23"]50[/TD]
[TD="class: xl65, width: 23"]52[/TD]
[TD="class: xl65, width: 23"]53[/TD]
[TD="class: xl65, width: 23"]56[/TD]
[TD="class: xl65, width: 23"]57[/TD]
[TD="class: xl65, width: 23"]58[/TD]
[TD="class: xl65, width: 23"]59[/TD]
[TD="class: xl65, width: 23"]60[/TD]
[TD="class: xl65, width: 23"]61[/TD]
[TD="class: xl65, width: 23"]62[/TD]
[TD="class: xl65, width: 23"]63[/TD]
[TD="class: xl65, width: 23"]64[/TD]
[TD="class: xl65, width: 23"]65[/TD]
[TD="class: xl65, width: 23"]66[/TD]
[TD="class: xl65, width: 23"]67[/TD]
[TD="class: xl65, width: 23"]68[/TD]
[TD="class: xl65, width: 23"]69[/TD]
[TD="class: xl65, width: 24"]80[/TD]
[TD="class: xl65, width: 23"]81[/TD]
[TD="class: xl65, width: 23"]82[/TD]
[TD="class: xl65, width: 23"]83[/TD]
[TD="class: xl65, width: 23"]84
[/TD]
[/TR]
[/TABLE]
Sub kt()
Dim DL, Chuoi, c As Long, r As Long, dic As Object, cot As Integer, i As Integer, tam
DL = Range("A2:CF16")
ReDim Chuoi(1 To UBound(DL, 2))
Set dic = CreateObject("scripting.dictionary")
With CreateObject("system.collections.Arraylist")
On Error Resume Next
cot = 0
For c = 1 To UBound(DL, 2)
For r = 1 To UBound(DL)
.Add DL(r, c)
Next r
.Sort
Chuoi(c) = Join(.ToArray)
.Clear
dic.Add Chuoi(c), ""
tam = dic.keys()(cot)
If Chuoi(c) = tam Then
cot = cot + 1
For i = 1 To 15
Cells(i + 18, cot) = DL(i, c)
Next
Cells(35, cot) = c
End If
Next c
End With
End Sub