Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Relating Worksheet(I).Name with VBComponent(J).Name

In the VBE, each Microsoft Excel Object has a VBComponent name and a
Worksheet name. Programatically, I can interrogate either the
Worksheets or the corresponding VBComponents. How do I tie the two
together?

Given a VBComponent (that is associated with a worksheet), how do I
determine its associated worksheet name or index?

Given a worksheet, how do I determine its associated VBComponent name
or index?

Thanks


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Relating Worksheet(I).Name with VBComponent(J).Name

MWE,

Given a VBComponent, you have to loop through the worksheets to
find the worksheet whose code name is the same as the VBComponent
name. E.g,

Function VBCompToWSName(VBComp As VBIDE.VBComponent) As String
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
If WS.CodeName = VBComp.Name Then
VBCompToWSName = WS.Name
Exit Function
End If
Next WS
End Function

Given a Worksheet, you can get its CodeName property to find the
associated VBComponent. For example,

Function WSToVBComp(WS As Worksheet) As VBIDE.VBComponent
Set WSToVBComp =
WS.Parent.VBProject.VBComponents(WS.CodeName)
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"MWE " wrote in message
...
In the VBE, each Microsoft Excel Object has a VBComponent name

and a
Worksheet name. Programatically, I can interrogate either the
Worksheets or the corresponding VBComponents. How do I tie the

two
together?

Given a VBComponent (that is associated with a worksheet), how

do I
determine its associated worksheet name or index?

Given a worksheet, how do I determine its associated

VBComponent name
or index?

Thanks


---
Message posted from http://www.ExcelForum.com/



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
Relating cells PaulinaDi Excel Worksheet Functions 3 October 17th 06 08:44 PM
VBIDE.VBComponent michaelberrier Excel Discussion (Misc queries) 3 June 12th 06 05:47 PM
Relating fields Henk Excel Discussion (Misc queries) 1 May 29th 06 11:33 AM
Relating text to a value SociologyStudent Excel Worksheet Functions 5 May 10th 06 08:21 PM
problem with wkbk.VBProject.VBComponent Rich[_14_] Excel Programming 0 September 11th 03 07:34 PM


All times are GMT +1. The time now is 02:47 AM.

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

About Us

"It's about Microsoft Excel"