unresolved post: Add in and the worksheetselectionchange interacti

  • Thread starter Thread starter filo666
  • Start date Start date
F

filo666

Hi, I posted the following question and remained unresolved:
On Thu, 22 Jan 2009 06:45:01 -0800, filo666

I made an Add In with a Workbook_SheetSelectionChange macro
so that the user of my add in will run the macro when he changes the cell
selection. The problem is that sience the add in work book is not
selection-changed, therefore the macro is not executed; how to tell VB that
the macro in the add in applies to all the open workbooks
(Workbook_SheetSelectionChange)?

Gord Dibben said:
Place this in your add-in Thisworkbook module

Private WithEvents XLApp As Excel.Application
Private Sub Workbook_Open()
Set XLApp = Excel.Application
End Sub
Private Sub XLApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
MsgBox "hello"
End Sub

THE PROBLEM:

when I try to get:
rw = ActiveWorkbook.ActiveSheet.Cells.Find(What:="*",
After:=ActiveSheet.Range("A1"), Lookat:=xlPart, LookIn:=xlFormulas, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
I get an error: Run-time error 91.

any help will be appreciated
 
I get an error: Run-time error 91.

This is the error when nothing is found. As you are looking for the
wildcard, I assume that you will get the error on an empty worksheet. Try the
following:-

Dim rngFind
Dim rw

Set rngFind = ActiveWorkbook.ActiveSheet.Cells.Find(What:="*", _
After:=ActiveSheet.Range("A1"), LookAt:=xlPart, LookIn:=xlFormulas, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False)

If Not rngFind Is Nothing Then
rw = rngFind.Row
End If
 
Back
Top