View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 363
Default Worksheet in VB COMPONENT

I'm using the following code to add an event procedure to a worksheets code.
Rather than having to refer to the worksheet
as "Sheet1", i would like to refer to the worksheet as its actual
name, which is 10. How could I do so? Thanks in advance. See
the following code where "SHEET1" is used.

Sub addactivate()
Dim StartLine As Long
With ActiveWorkbook.VBProject.VBComponents("SHEET1").Co deModule
StartLine = .CreateEventProc("Activate", "Worksheet") + 1
.InsertLines StartLine, _
"If lastAddress < """" Then Range(lastAddress).Select"
End With

End Sub