MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

User-data types: loading data, Equivalence or Alias possible?

  Asked By: Michael    Date: Aug 20    Category: MS Office    Views: 770

I want to be able to load data from a sheet as follows:
Dim x() as variant
This loads the rows & columns of range into x(i,j) just fine.

But I want to use/refer to the data in a custom structure, e.g.:

Can I create an "equivalence" (Fortran style) between x & y so one
does not have to loop through x cell by cell, and then populate each
element of y?

I tried posting this in Excel Forums, but the responders did not
understand. Am trying again here.



1 Answer Found

Answer #1    Answered By: Ryan Evans     Answered On: Aug 20

There is no equivalent to the equivalence. :-) In fact, FORTRAN and COBOL
(redefine) are the only languages I can think of that offer this. (And a
good thing too - it was always a problem - both for programmers and

If you want a custom  structure, then you'll need to load  it into that in the
first place, or transfer the information from the X array to the Y array of
structures yourself.

It's easy to create  an array of a structured item. You can either use a
Private Type and fill the items yourself, or use a Class module and
encapsulate the filling of the items in the class.

Look at what you get if you pass X(I) to a variant parameter of a sub - it's
likely that you'll get a single-dimension array (being the second
dimension). Your class could work through this and set the individual