2

I have a data object

I also have arrays of these data objects

I want to put these arrays of data objects into another array

Dim ArrayOfDataObjects1(10) as new DataObject
Dim ArrayOfDataObjects2(10) as new DataObject
Dim ArrayOfDataObjects3(10) as new DataObject

'Now, I want to put all of these into another array, how can I?

Thanks!

edit: I know I need to create another array with size 3, but what type do I define the array as?

1
  • Wouldn't a collection do the job? Commented Dec 1, 2010 at 19:16

1 Answer 1

4

If you are not concerned with type-safety, you could use Variant. Example in Excel VBA:

Sub a()
Dim ArrayOfDataObjects1(10) As Worksheet
Dim ArrayOfDataObjects2(10) As Worksheet
Dim ArrayOfDataObjects3(10) As Worksheet

Dim arr(3) As Variant

Set ArrayOfDataObjects1(1) = ActiveSheet

arr(1) = ArrayOfDataObjects1

arr(2) = ArrayOfDataObjects2

arr(3) = ArrayOfDataObjects3

MsgBox arr(1)(1).Name

End Sub
Sign up to request clarification or add additional context in comments.

4 Comments

I think using a Variant is the only way to do this, whether you're concerned with type safety or not.
@jtolle I think you may create a Class Module to create objects to hold those values. But never did it, so ...
Sure, I just meant that there is no VBA syntax to describe a strongly-typed array of array of dataobject...
@jtolle Ahh OK. I misunderstood you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.