R
rickle
I have an excel macro that runs to set my default find/search values so
that it searches by columns and looks in the values rather than
formulas. There is one more value I'd like changed...I'd like to have
the default find to look at the whole workbook, rather than just sheet.
I'm sure it's just a single line that needs to be added to the class,
I just don't know what that line is.
Here's what I have in my personal.xls:
# (in module1)
Public gclsEventHandler As Class1
Sub auto_open()
Set gclsEventHandler = New Class1
End Sub
# (in class1)
Private WithEvents mxlApp As Excel.Application
Private Sub Class_Initialize()
Set mxlApp = Excel.Application
End Sub
Private Sub Class_Terminate()
Set mxlApp = Nothing
End Sub
Private Sub mxlApp_WorkbookOpen(ByVal Wb As Excel.Workbook)
''' Ignore this workbook and any add-ins.
If Wb.Name <> ThisWorkbook.Name And Not Wb.IsAddin Then
Dim FoundCell As Range
With ThisWorkbook.Worksheets(1)
.Range("a1").Value = ""
Set FoundCell = .Cells.Find(What:="", _
After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False)
.Parent.Close savechanges:=False
End With
MsgBox Wb.Name & " was just opened."
End If
End Sub
that it searches by columns and looks in the values rather than
formulas. There is one more value I'd like changed...I'd like to have
the default find to look at the whole workbook, rather than just sheet.
I'm sure it's just a single line that needs to be added to the class,
I just don't know what that line is.
Here's what I have in my personal.xls:
# (in module1)
Public gclsEventHandler As Class1
Sub auto_open()
Set gclsEventHandler = New Class1
End Sub
# (in class1)
Private WithEvents mxlApp As Excel.Application
Private Sub Class_Initialize()
Set mxlApp = Excel.Application
End Sub
Private Sub Class_Terminate()
Set mxlApp = Nothing
End Sub
Private Sub mxlApp_WorkbookOpen(ByVal Wb As Excel.Workbook)
''' Ignore this workbook and any add-ins.
If Wb.Name <> ThisWorkbook.Name And Not Wb.IsAddin Then
Dim FoundCell As Range
With ThisWorkbook.Worksheets(1)
.Range("a1").Value = ""
Set FoundCell = .Cells.Find(What:="", _
After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False)
.Parent.Close savechanges:=False
End With
MsgBox Wb.Name & " was just opened."
End If
End Sub