nigelandrewfoster
Well-known Member
- Joined
- May 27, 2009
- Messages
- 747
Hello, feeling my way forward in object oriented approach to structuring my code. Quick question. In the example I'm working on I have a class called clsTeam. I give the team a name using oTeam.Name="Team 1", for example:
How can I modify the code so that it always takes the value from a table of names in the worksheet please (i.e. is always linked to the cell object)? What I want to be able to achieve is to be able to use Teams(1).Name to retrieve the cell contents of cell A2 in a worksheet, Teams(2).Name to retrieve the name in A3, etc. Once I have learned to do this, I can then utilise Teams(1).Colour to retrieve the .Interior.Color property of that cell directly. Is this possible? The only way forward I could think of was by retrieving the index of the Team object from the Teams collection and using that as an offset, but couldn't get any further.
Thanks for your time.
Code:
Option Explicit
Private pName As String
Public Property Get Name() As String
Name = pName
End Property
Public Property Let Name(Value As String)
pName = Value
End Property
How can I modify the code so that it always takes the value from a table of names in the worksheet please (i.e. is always linked to the cell object)? What I want to be able to achieve is to be able to use Teams(1).Name to retrieve the cell contents of cell A2 in a worksheet, Teams(2).Name to retrieve the name in A3, etc. Once I have learned to do this, I can then utilise Teams(1).Colour to retrieve the .Interior.Color property of that cell directly. Is this possible? The only way forward I could think of was by retrieving the index of the Team object from the Teams collection and using that as an offset, but couldn't get any further.
Thanks for your time.
Last edited: