【发布时间】:2017-02-05 05:35:14
【问题描述】:
我想为工作表中的所有单元格清空单元格格式并将其设置为常规:
- 包含“MyText”和
- 格式为百分比
我正在使用查找和替换对话框 (CTRL+H),但是:
- 如果我将“替换为”框留空,则只替换格式; “MyText”仍然存在;
- 如果我在“替换为”框中写入“SomeText”,也会执行文本替换,以及格式替换
看来我无法一次性获得两个替换项(空文本和更改的格式)。
是否有可以在“替换为:”字段中使用的“无”通配符?或者任何其他简单的解决方案?
更新: 我尝试录制宏。 这会进行文本和格式替换:
Application.FindFormat.NumberFormat = "0.00%"
Application.ReplaceFormat.NumberFormat = "General"
Cells.Replace What:="MyText", Replacement:="nothing", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=True, _
ReplaceFormat:=True
但是如果我删除替换文本,它只会进行格式替换(这在某种程度上是有意义的,但这不是我想要实现的)
Application.FindFormat.NumberFormat = "0.00%"
Application.ReplaceFormat.NumberFormat = "General"
Cells.Replace What:="MyText", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=True, _
ReplaceFormat:=True
【问题讨论】:
-
单元格是否包含 text 或 formulas 返回文本??
-
@Gary'sStudent :没有公式,只有文本;如果它有公式,则文本替换根本不起作用;但如果我提供这个论点,它就会起作用;我只需要知道如何提供
blank参数;""不工作...