Hi Dave,
So you want Sheet1's worksheet_Change event to use the same address as the
cell
that got double clicked on in sheet2?
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
Cancel = True
Sheet1.Worksheet_Change sheet1.Range(target.address)
End Sub
this works. But I'd like to know how this works for application or workbook
events - how can I pass the required arguments? I wrote all errors I get as
comments.
1)Workbook event
How can this be done using the Workbook_SheetChange event? I have this code
for the workbook:
Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Sh.Target.Interior.ColorIndex = 5 'does not work:Error 438, Object does
not support this method or attribute
End Sub
In Sheet2 I have:
Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Workbook_SheetChange Sheets(1), Sheet1.Range(Target.Address)
'does not work: sub or function not defined
End Sub
2) Application event
The I tried the class module with Application_sheetchange:
Class Module:
Dim WithEvents app As Application
Sub app_SheetChange(ByVal Sh As Object, ByVal Target As Range)
MsgBox "hi"
End Sub
normal Module:
Dim WithEvents app As Application 'error: user defined type not defined
Private Sub app_SheetChange(ByVal Sh As Object, ByVal Target As Range)
MsgBox "hi"
End Sub
Code for sheet2:
Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
app_SheetChange Sheets(1), sheet1.Range(Target.Address)
'error: sub or function not defined
End Sub
How can I pass the object and the target to either application events or
workbook events?
regards
arno