Private Sub CommandButton1_Click()
For Each sht In ActiveWorkbook.Worksheets
sht.Cells.Replace what:=TextBox1.Text, Replacement:=TextBox2.Text, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next sht
UserForm1.Hide
End Sub
Autohotkey can filter by window title and text. Like this:
#SingleInstance
#Persistent
loop:
WinWaitActive, Microsoft Excel, All done
{
WinClose
}
Goto, loop
As you can probably tell there’s no easy solution.
It’s probably just better to train yourself to close the window with [Enter], [Esc] (excel 2010) which can be done without removing your hands from the keyboard (assuming you’re already using Ctrl+H and Tab to open find/replace and navigate). Really, 5 minutes of training can create the muscle memory needed to optimize this action. (My personal mantra is unless you’re using charts, pivot tables, or other arcane controls there’s no reason to use the mouse in excel, it just slows you down)
Can you explain why this isn’t an option? It may open avenues to other solutions.