mikerickson
MrExcel MVP
- Joined
- Jan 15, 2007
- Messages
- 24,355
I am working with custom classes. Two classes in particular, clsPeople and clsWorkingGroup. A clsWorkingGroup object is basically a collection of clsPeople objects.
A clsPeople object has a WorkingGroup property which is the clsWorkgingGroup object which that person is a member of.
I can add and remove individual clsPeople to a clsWorkingGroup fine. Individual changes to APerson.WorkingGroup are reflected in the .WorkingGroup property of the other member's of that group.
My difficulty is when I try to merge two WorkingGroups. If I have APerson.WorkingGroup and BPerson.WorkingGroup and merge them, I could either
1) add all the members of APerson.WorkingGroup to BPerson.WorkingGroup and vice-versa. The problem is that would result in two different clsWorkingGroup objects with the same members, but different objects. Future changes to APerson.WorkingGroup would not be reflected in BPerson.WorkingGroup.
2) or I could create a new clsWorkingGroup object, fill it with the members of both APerson.WorkingGroup and BPerson.WorkingGroup and then go back and assign that new group to the WorkingGroup property of everyone's clsPerson object. That would work fine but consider
The difficulty with 2) is that any previous variables of those WorkingGroups lose their value when merged.
How can I merge two clsWorkingGroup objects so that they become one object, but without losing the value that previous arguments might have to one or the other of those clsWorkingGroup objects?
Unless I can find a solution to this dilemma, I'm going to have to go with #2.
A clsPeople object has a WorkingGroup property which is the clsWorkgingGroup object which that person is a member of.
I can add and remove individual clsPeople to a clsWorkingGroup fine. Individual changes to APerson.WorkingGroup are reflected in the .WorkingGroup property of the other member's of that group.
My difficulty is when I try to merge two WorkingGroups. If I have APerson.WorkingGroup and BPerson.WorkingGroup and merge them, I could either
1) add all the members of APerson.WorkingGroup to BPerson.WorkingGroup and vice-versa. The problem is that would result in two different clsWorkingGroup objects with the same members, but different objects. Future changes to APerson.WorkingGroup would not be reflected in BPerson.WorkingGroup.
2) or I could create a new clsWorkingGroup object, fill it with the members of both APerson.WorkingGroup and BPerson.WorkingGroup and then go back and assign that new group to the WorkingGroup property of everyone's clsPerson object. That would work fine but consider
VBA Code:
' pseudo code
Dim OneGroup as clsWorkingGroup
Set oneGroup = APerson.WorkingGroup
MergeGroups APerson.WorkingGroup, BPerson.WorkingGroup
' what of oneGroup.
The difficulty with 2) is that any previous variables of those WorkingGroups lose their value when merged.
How can I merge two clsWorkingGroup objects so that they become one object, but without losing the value that previous arguments might have to one or the other of those clsWorkingGroup objects?
Unless I can find a solution to this dilemma, I'm going to have to go with #2.