View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default add eventhandler to sheet in code

Not sure what you are asking, and what the relevance of the DoubleClick
event is. Maybe you simply want something like this

Private Sub Workbook_NewSheet(ByVal Sh As Object)
If TypeName(Sh) = "Worksheet" Then
Set gwsUpload = Sh
MsgBox Sh.Name & " assigned to gwsUpLoad"
' code ?
End If
End Sub

I am assuming gwsUpload is a global worksheet variable declared in a normal
module

If(?) you have a Form Ingave showing it might be better to update a Property
in the Form and call some routine in the Form.

Regards,
Peter T

"King Albert II" wrote in message
6.253...
Hi,


I'd like to attach the eventhandler below, to any sheet that I add in
code like so : Set wsUpload = ThisWorkbook.Worksheets.Add




Private Sub Worksheet_BeforeDoubleClick(ByVal target As Range, Cancel As
Boolean)


Call bereikenmaken
If target.Column = Range("womschrijving").Column Then
Load Ingave
Call tonen(target)
Ingave.Show
End If


End Sub





How can I do that ?

thx

Ward