Hello,
I'm trying to set up a default when Excel opens up so that when the user starts, 'CTRL-F' default option is within 'workbook'. (The default is within 'sheet').
I know that it's some .Find property I can set up as a Workbook_Open function under "ThisWorkbook" module. But I have been unsuccessful here. anyone know the exact code to use?
OR
I can override the default FIND wiht this code I made which searches thru all the sheets. My only problem here is that I cannot stop it from erroring all the time after it finds the text. Here is the code:
*******************************
Sub FindChemical()
On Error GoTo errorHandler
Dim Chemical As String
Dim MyRange As Range
Dim sh As Worksheet
Chemical = InputBox("Enter the Chemical to Search for")
If Chemical = "" Then End
For Each sh In ActiveWorkbook.Worksheets
With sh.Cells
Cells.Find(What:=Chemical, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
End With
Next sh
MsgBox ("acknowledge")
errorHandler:
MsgBox "There has been an error: " & Error() & Chr(13) _
& "Ending Sub.......Please try again", 48
End Sub
***********************
Help with solving either of these would be most appreciated. I would prefer the first option, but the second option would be great too!
Thanks!
I'm trying to set up a default when Excel opens up so that when the user starts, 'CTRL-F' default option is within 'workbook'. (The default is within 'sheet').
I know that it's some .Find property I can set up as a Workbook_Open function under "ThisWorkbook" module. But I have been unsuccessful here. anyone know the exact code to use?
OR
I can override the default FIND wiht this code I made which searches thru all the sheets. My only problem here is that I cannot stop it from erroring all the time after it finds the text. Here is the code:
*******************************
Sub FindChemical()
On Error GoTo errorHandler
Dim Chemical As String
Dim MyRange As Range
Dim sh As Worksheet
Chemical = InputBox("Enter the Chemical to Search for")
If Chemical = "" Then End
For Each sh In ActiveWorkbook.Worksheets
With sh.Cells
Cells.Find(What:=Chemical, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
End With
Next sh
MsgBox ("acknowledge")
errorHandler:
MsgBox "There has been an error: " & Error() & Chr(13) _
& "Ending Sub.......Please try again", 48
End Sub
***********************
Help with solving either of these would be most appreciated. I would prefer the first option, but the second option would be great too!
Thanks!