Excel单元格。替换问题

Excel单元格。替换问题,excel,vba,replace,Excel,Vba,Replace,当我使用Cell.Replace时,用日期替换变量excel会更改我的日期格式。(见图) 我已尝试将ReplaceFormat选项更改为True。。。见下文 Cells.Replace What:=VariableName, Replacement:=VariableValue, LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=True

当我使用Cell.Replace时,用日期替换变量excel会更改我的日期格式。(见图)

我已尝试将ReplaceFormat选项更改为True。。。见下文

Cells.Replace What:=VariableName, Replacement:=VariableValue, LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=True

您可以使用查找/替换,并在替换时使用指定的格式。在
单元格上方添加此行。替换…
行:

Application.ReplaceFormat.NumberFormat = "MM/DD/YYYY H:MM AM/PM"

可以你有错误吗?它不会给出错误,但会产生意外的结果吗?问题是什么?对不起,没有错。此图显示了运行replace的结果。我的意图是用MM/DD/YY H:MM AM/pm替换格式谢谢Wayne先生。这似乎是可行的,但是,我有一个循环,其中每个循环实例之间的格式设置。@JacobMF-那么您可以只设置一次格式,或者创建一个格式列表?无论如何,这听起来像是一个全新的问题。@JacobMF-这个答案对你有用吗?如果是这样,您可以通过单击帖子左侧的复选标记来标记为答案,它会将此帖子从未应答队列中删除。