|
楼主 |
发表于 2015-7-22 11:36
|
显示全部楼层
我想用第n行的数据依次与前面n-1个数据做相似比较。程序如下Sub Warn_Same()
Dim Str1 As String
Dim Str2 As String
Dim p As Integer
Dim q As Integer
Dim count As Integer
Dim a As Integer
Dim b As Integer
Dim m As Integer
Dim n As Integer
Dim i As Integer
n = Range("E65536").End(xlUp).Row
For i = 1 To n - 1
Str1 = Range("E1:E65536").Cells(i)
Str2 = Range("E1:E65536").Cells(n)
a = Len(Str1)
b = Len(Str2)
If a > b Then
m = b
ElseIf a < b Then
m = a
Else: m = a
End If
Next
For count = 1 To m
If Mid(Str1, count, 1) = Mid(Str2, count, 1) Then
p = p + 1
ElseIf Mid(Str1, count, 1) <> Mid(Str2, count, 1) Then
q = q + 1
End If
Next
If p >= q Then
MsgBox ("The Two Strings Are Same ")
End If
End Sub
但是因为m值时刻在变化,导致结果会出现bug。感觉是循环过程出的问题,新手望指点
|
|