您的位置:首页 > 其它

两种不同方法判断Excel表格中是否存在指定数值

2012-04-10 17:58 387 查看
第一种方法,使用For循环:

For Each cell In Range("I1:I1000")
i = InStr(cell.Value, "1050")
If i > 0 Then
bExist = True
Exit For
End If
i = 0
Next


第二种方法,使用Do循环:

''' Another way to realize
i = 1
Do Until (i > Range("I1:I1000").Cells.Count)
If InStr(Range("I1:I1000").Cells(i).Value, "1050") > 0 Then
bExist = True
Exit Do
End If
i = i + 1
Loop
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: