6

次のコードの最初の行を実行した後、Excelはユーザー インターフェイスの [セルの内容全体に一致]設定を変更します。その結果、次にユーザーがCtrl+Fを押すと、セルの内容全体で検索が実行されます。ユーザー エクスペリエンスに影響を与える設定を変更する VBA マクロは好きではないので、常に 2 行目を実行します。これは別の検索を実行し、[セルの内容全体を一致させる] を既定値に戻します。

'execute the find and changes the entire cell content setting
Set C = MyRange.Find(SomeText, LookAt:=xlWhole)

'put the setting back to the default value (not the previous value)
MyRange.SomeText ParName, LookAt:=xlPart

問題は、ユーザーが最後に設定した値ではなく、デフォルトに戻すことです。

私はむしろ次のようなものが欲しいです:

'store the current entire cell content setting
OldLookAt = Application.FindLookAt

'execute the find
Set C = MyRange.Find(SomeText, LookAt:=xlWhole)

'restore the original setting
Application.FindLookAt = OldLookAt

Application.FindLookAt見つからなかったので作りました。

Range.Findユーザーエクスペリエンスに影響を与えずに何かをする方法はありますか?

4

2 に答える 2