I have a situation in VBA where I have an array of elements of my own user defined type.
The type is as follows:
Type CommentInfoStruct
REF As String ' a reference for an item, usually a single letter
NB As Long ' number of items
COMMENT As String ' comment on item, eg "This item needs special paint colour"
End Type
Essentially what I need to do is loop through the array, and check if there are items where the COMMENT
matches between two items. If they do match, I need to combine the two items into one like so:
Item A:
REF="A"
NB=2
COMMENT="Special colour"
Item B:
REF="B"
NB=3
COMMENT="Special colour"
New item (stored at previous index of Item A, with Item B now deleted from the array):
REF="A/2,B/3"
NB=5
COMMENT="Special colour"
What's the cleanest way to do this? I've searched and can't seem to find a simple way of deleting array elements and feel I must be missing something. Also keeping track of the limits of the loops I've tried to write seems tricky (since the array redims within the loops).