我有以下代码来查找单元格是否具有特定值“0.0”。但是,我没有意识到,如果10.0是一个值,程序也会选择它。如何修改代码以仅提取0.0?
Sub ReformatDeplete()
Dim SrchRng3 As Range
Dim c3 As Range, f As String
Set SrchRng3 = Worksheets("Melanoma").Range("M4", Worksheets("Melanoma").Range("M65536").End(xlUp))
Set c3 = SrchRng3.Find("0.0", LookIn:=xlValues)
If Not c3 Is Nothing Then
f = c3.Address
Do
With Worksheets("Melanoma").Range("A" & c3.Row & ":M" & c3.Row)
.Font.ColorIndex = 1
.Interior.ColorIndex = 16
End With
Set c3 = SrchRng3.FindNext(c3)
Loop While c3.Address <> f
End If
End Sub
任何建议都将不胜感激。
先谢谢!
答案 0 :(得分:4)
您正在寻找Lookat
函数的.Find
参数。
Set c3 = SrchRng3.Find("0.0", LookIn:=xlValues, Lookat:=xlWhole)
此参数有两个常量,xlPart
和xlWhole
。正如您所注意到的,如果未指定,则该函数默认为xlPart
。
要详细了解.Find
功能,check out this link.