我需要找到一个字符串“c =”,而我正在寻找的单元格的值是“c = 0.32”。
问题是在同一范围内,我有一个值为“blablac = 54”的单元格,它首先出现,并且
Dim x as Integer
x = Find("c =", MatchCase:=True).row
函数,返回那个,而不是“c = 0.32”。
如何告诉 find 函数在单元格值的开头查找字符串,以便获得正确的值?
最佳答案
您可以使用通配符 What:="c =*"
并使用 LookAt:=xlWhole
(用于匹配整个单词)。在那种情况下 Find
将只返回单元格,其值从 c =
开始:
Dim x As Long
Dim rng As Range
Set rng = Find(What:="c =*", LookAt:=xlWhole, MatchCase:=True)
If Not rng Is Nothing Then
x = rng.Row
End If
关于excel - VBA - 从头开始查找字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22473384/