- Tham gia
- 8/6/06
- Bài viết
- 14,576
- Được thích
- 22,897
- Nghề nghiệp
- U80
Ví dụ:
A|B
|
|
X
|
|
|
X|
|
|
|
|
X|
|
|
|
|
|
|
X|
|
|
|
XX|
|
|
|
|
X|
|
|
|
X
|
|
|
X|
|
|
|
|
X|
|
|
|
|
|
|
X|
|
|
|
XX|
|
|
|
|
X|
|
PHP:
Option Explicit
Sub MaxRow()
Dim Rng As Range, sRng As Range
Dim MyAdd As String, MAdd As String
Dim Zz1 As Long, Zz2 As Long, jJ As Long, ZMax As Long
Set Rng = Range("A1:A" & [a65500].End(xlUp).Row)
Set sRng = Rng.Find("X", , xlFormulas, xlWhole)
If Not sRng Is Nothing Then
MyAdd = sRng.Address
Do
jJ = jJ + 1
If jJ Mod 2 = 1 Then Zz1 = sRng.Row Else Zz2 = sRng.Row
If Abs(Zz2 - Zz1) > ZMax Then
ZMax = Abs(Zz2 - Zz1): MAdd = sRng.Address & Str(Abs(Zz2 - Zz1))
End If
Set sRng = Rng.FindNext(sRng)
Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
End If
MsgBox MAdd
End Sub
Chỉnh sửa lần cuối bởi điều hành viên: