Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Worksheet in VB COMPONENT

Do you mean

With
ActiveWorkbook.VBProject.VBComponents(Worksheets(" 10").CodeName).CodeModule

--
HTH

Bob Phillips

"Al" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Worksheet in VB COMPONENT

Sub addactivate()
Dim StartLine As Long
Dim s As String
s = ActiveworkBook.Worksheets("10").Codename
With ActiveWorkbook.VBProject.VBComponents(s).CodeModul e
StartLine = .CreateEventProc("Activate", "Worksheet") + 1
.InsertLines StartLine, _
"If lastAddress < """" Then Range(lastAddress).Select"
End With

End Sub

--
Regrds,
Tom Ogilvy



"Al" wrote in message
...
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



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

Thanks Bob and Tom!!

"Bob Phillips" wrote:

Do you mean

With
ActiveWorkbook.VBProject.VBComponents(Worksheets(" 10").CodeName).CodeModule

--
HTH

Bob Phillips

"Al" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SUMPRODUCT with an OR component andy62 Excel Discussion (Misc queries) 5 June 11th 09 10:01 PM
Office web component . Ermias Excel Worksheet Functions 0 May 20th 08 11:40 PM
Web Excel Component Bug [email protected] Excel Discussion (Misc queries) 1 May 11th 07 12:22 AM
Changing VB Component Names to match Worksheet names using VBE Philip Excel Programming 1 April 12th 05 05:37 PM
Chart component Mika[_2_] Excel Programming 0 June 6th 04 04:23 PM


All times are GMT +1. The time now is 08:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"