重置对话框的参数 Excel "Find and Replace"

如何以编程方式重置对话框的参数 Excel
Find and Replace

在默认值上 /"找什么", "取而代之", "Within", "Search"," 查看B."," 匹配寄存器","匹配单元格的所有内容"/?

我用
Application.FindFormat.Clear


Application.ReplaceFormat.Clear

重置搜索和替换格式。

我想知道在使用后是什么
expression.Replace/FindWhat, ReplaceWhat, After, MatchCase, WholeWords/

线
FindWhat

显示在对话框中
Find and Replace

, 但不是参数
ReplaceWhat

.
已邀请:

八刀丁二

赞同来自:

您可以使用此宏重置。 find & replace. 不幸的是,你必须打电话给他们,因为有一个或两个参数,每个人都是独一无二的,所以如果你想丢失一切,你就会被困。 没有 'reset', 因此,我发现的唯一方法 - 这是一个假的替代品。 find & 使用默认参数。


Sub ResetFind//
Dim r As Range

On Error Resume Next 'just in case there is no active cell
Set r = ActiveCell
On Error Goto 0

Cells.Find what:="", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False
Cells.Replace what:="", Replacement:="", ReplaceFormat:=False

If Not r Is Nothing Then r.Select
Set r = Nothing
End Sub

知食

赞同来自:

您可以使用以下命令打开对话框。 "Replace" 填充领域:

Application.Dialogs/xlDialogFormulaReplace/。这里沟通参数

-

参数列表是takov

搜索线, replace_text, look_at, look_by, active_cell, match_case, match_byte

到目前为止,我发现的唯一方法 'click' 纽扣, - 这是 SendKey.

经过长期的研究和测试,我现在知道你想做什么,但我不认为它可以完成 /没有 SendKey/. 它看起来像 Excel 有一个错误不会转售替换值 /的 VBA/, 无论你想要安装什么。

我真的找到了这种方式 'faster', 哪些人发表了 MSDN, 所以你可以尝试。

http://social.msdn.microsoft.c ... a98a/

石油百科

赞同来自:

我检查了它,它有效。 我从几个地方借了细节


Sub RR0// 'Replace Reset & Open dialog /specs: clear settings, search columns, match case/

'Dim r As RANGE 'not seem to need
'Set r = ActiveCell 'not seem to need
On Error Resume Next 'just in case there is no active cell
On Error GoTo 0

Application.FindFormat.Clear 'yes
Application.ReplaceFormat.Clear 'yes

Cells.find what:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext
Cells.Replace what:="", Replacement:="", ReplaceFormat:=False, MatchCase:=True 'format not seem to do anything
'Cells.Replace what:="", Replacement:="", ReplaceFormat:=False 'orig, wo matchcase not work unless put here - in replace

'If Not r Is Nothing Then r.Select 'not seem to need
'Set r = Nothing

'settings choices:
'match entire cell: LookAt:=xlWhole, or: LookAt:=xlPart,
'column or row: SearchOrder:=xlByColumns, or: SearchOrder:=xlByRows,

Application.CommandBars/"Edit"/.Controls/"Replace..."/.Execute 'YES WORKS
'Application.CommandBars/"Edit"/.Controls/"Find..."/.Execute 'YES same, easier to manipulate
'Application.CommandBars.FindControl/ID:=1849/.Execute 'YES full find dialog

'PROBLEM: how to expand options?
'SendKeys /"%{T}"/ 'alt-T works the first time, want options to stay open

Application.EnableEvents = True 'EVENTS

End Sub

卫东

赞同来自:

无需使用 sendkeys 您可以轻松地指重置对话框值所需的值。


Sub ResetFindReplace//
'Resets the find/replace dialog box options
Dim r As Range

On Error Resume Next

Set r = Cells.Find/What:="", _
LookIn:=xlFormulas, _
SearchOrder:=xlRows, _
LookAt:=xlPart, _
MatchCase:=False/

On Error GoTo 0

'Reset the defaults

On Error Resume Next

Set r = Cells.Find/What:="", _
LookIn:=xlFormulas, _
SearchOrder:=xlRows, _
LookAt:=xlPart, _
MatchCase:=False/

On Error GoTo 0
End Sub

要回复问题请先登录注册