- Tham gia
- 8/6/06
- Bài viết
- 14,575
- Được thích
- 22,895
- Nghề nghiệp
- U80
Tất nhiên là được mà bạn:
PHP:
Option Explicit
Sub First15ColumnIn2RowsHasValues()
Dim jJ As Long, Ww As Long, Col As Byte, Ff As Byte
Dim Rws As Long, Timer_ As Double: Const H7 As Byte = 15
Dim jRng As Range, wRng As Range, sRng As Range
Sheet1.Select: Timer_ = Timer
Rws = [A65500].End(xlUp).Row: Col = [Iv2].End(xlToLeft).Column
Sheet2.[a1].Resize(3 * Rws, Col).Clear
For jJ = 4 To Rws - 1
Set jRng = Cells(jJ, "B").Resize(, H7)
For Ww = jJ + 1 To Rws
Set wRng = Cells(Ww, "B").Resize(, H7)
For Ff = 2 To H7
Set sRng = Union(Cells(jJ, Ff), Cells(Ww, Ff))
If Application.WorksheetFunction.Sum(sRng) < 1 Then
Exit For
End If
Next Ff
If Ff >= H7 Then
With Sheet2.[A65500].End(xlUp).Offset(2)
.Resize(, Col).Value = Cells(jJ, "A").Resize(, Col).Value
.Offset(1).Resize(, Col).Value = Cells(Ww, "A").Resize(, Col).Value
If Ff > H7 Then _
.Offset(, H7 - 14).Resize(2, Ff).Font.ColorIndex = 3
End With
End If
Next Ww
Next jJ
Sheet2.[a1].Value = Timer() - Timer_: Sheet2.Select
End Sub