在电子表格中特定的 1 列范围内,我需要使用 Excel 2007 VBA 的range.find
方法来定位包含 2 字符长值的文本值单元格:8"(在美国发音为 8 英寸)。.find
方法是在一个对它正在执行的所有其他搜索都很好的子中,但它似乎找不到 8",或者实际上找不到任何带有尾随双引号的文本值。
在下面的代码中,最初sComparisonText
包含8"
sComparisonText
我尝试在,的末尾添加 1 到 6 个双引号Chr(34)
,但 .find 方法仍然返回 Nothing。
各种搜索都注意到了这种Chr(34)
方法,并且还堆叠了双引号: """"
resolves to "
,""""""
resolves to""
等。我还研究了.find
具有特殊转义字符的方法,但也没有成功。
If Right(sComparisonText, 1) = """" Then
sComparisonText = sComparisonText & Chr(34) & Chr(34) & Chr(34) & Chr(34) & Chr(34) & Chr(34)
End If
Set rResult = rCT.Columns(InputColumn).Find(What:=sComparisonText, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If (rResult Is Nothing) Then 'Add a new row to the bottom of the rCT range
有人可以告诉我我做错了什么吗?
非常感谢!戴夫