VBA 只替换整个字符串
VBA replace only whole string
使用 VBA 中的替换,replaces
find
的所有出现。如果 find
是整个字符串,我如何限制它只替换?
Cells.Replace What:="0", Replacement:="n/a", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
将 12034
和 0
替换为 12n/a34
和 n/a
相反,将忽略 12034
,仅将 0
替换为 n/a
将 LookAt:=xlPart
更改为 LookAt:=xlWhole
xlPart
将匹配单元格内的任何文本,而 xlWhole
将仅匹配整个单元格条目。
使用 VBA 中的替换,replaces
find
的所有出现。如果 find
是整个字符串,我如何限制它只替换?
Cells.Replace What:="0", Replacement:="n/a", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
将 12034
和 0
替换为 12n/a34
和 n/a
相反,将忽略 12034
,仅将 0
替换为 n/a
将 LookAt:=xlPart
更改为 LookAt:=xlWhole
xlPart
将匹配单元格内的任何文本,而 xlWhole
将仅匹配整个单元格条目。