After you run the first line of the following code, Excel changes the Match All Cell Content option in the user interface. As a result, the next time the user presses Ctrl + F , the search is performed in the entire contents of the cell. I don’t like the VBA macro, which changes the setting that affects the user interface, so I always run the second line, which does a different search, and sets the Match all cell contents to default value .
'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
The problem is that it returns the default value, not the value that the user last set.
I would prefer something like:
'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
I made up Application.FindLookAtbecause I could not find it.
Is there a way Range.Findto something without affecting the user?
source
share