emgaingayngo
Thành viên hoạt động
- Tham gia
- 9/2/07
- Bài viết
- 141
- Được thích
- 5
Option Explicit
Sub ToHopChap4()
On Error Resume Next
Dim Zj As Integer, Zf As Byte, Zw As Byte, Zz As Byte
Dim eRow As Long
Const Gn As String = "-"
eRow = [A65432].End(xlUp).Row: Range("C1:C" & eRow + 9).Clear
Range("A1:A" & eRow).SpecialCells(xlCellTypeBlanks).Select
If Not Selection Is Nothing Then Selection.Delete Shift:=xlUp
eRow = [A65432].End(xlUp).Row
For Zf = 1 To eRow - 3
For Zj = Zf + 1 To eRow - 2
For Zw = Zj + 1 To eRow + 1
For Zz = Zw + 1 To eRow
[c65432].End(xlUp).Offset(1) = Cells(Zf, 1) & Gn & Cells(Zj, 1) & Gn _
& Cells(Zw, 1) & Gn & Cells(Zz, 1)
Next Zz, Zw, Zj, Zf
End Sub
Có khi nó gôm cả các dòng ghi chú của bạn vô làm luôn đó!
....
Cells(1,3).select
End Sub
Range("C1:C1000").Clear
Option Explicit
Sub ToHopChap4()
On Error Resume Next
Dim Zj As Integer, Zf As Byte, Zw As Byte, Zz As Byte
Dim eRow As Long: Dim bRng As Range '<<=='
Const Gn As String = "-"
eRow = [A65432].End(xlUp).Row
Range([C1], [c65500].End(xlUp)).Clear '<<=='
Set bRng = Range("A1:A" & eRow).SpecialCells(xlCellTypeBlanks) '<<=='
If Not bRng Is Nothing Then bRng.Delete Shift:=xlUp '<<=='
eRow = [A65432].End(xlUp).Row
For Zf = 1 To eRow - 3
For Zj = Zf + 1 To eRow - 2
For Zw = Zj + 1 To eRow + 1
For Zz = Zw + 1 To eRow
[c65432].End(xlUp).Offset(1) = Cells(Zf, 1) & Gn & Cells(Zj, 1) & Gn _
& Cells(Zw, 1) & Gn & Cells(Zz, 1)
Next Zz, Zw, Zj, Zf
End Sub