Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transferring data between arrays VBA Excel

Status
Not open for further replies.
Mar 12, 2001
30
0
0
GB
Does anyone know how to move data from a 3-dimensional array into a 2-dimensional array using VBA in Excel?

I'd like to select one dimension and hold it constant and then simply transfer data relating to the other 2 dimensions across into a new 2-D array.

Eg., Array1(Colour,Size,Cost) and Array2(Size,Cost)

I simply want to select a colour from Array1 and copy the corresponding size and cost elements into Array2.

Other than looping through using a for..next loop is there a quicker or simpler alternative?

Cheers
 
Could you not just use the relevent elements of the existing array?

Never knock on Death's door: ring the bell and run away! Death really hates that!
 





Hi,

Could be. Might depend on how the data is organized on your array, taking some cues from sorting theory. Maybe guessing at where in the array bounds to begin (some hashing algorithm???), rather than at the beginning, and then using some logic to search forwar or backward from that point.

But what's the heartburn with a straight loop???

Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
Thanks for responding guys.

The initial reason why I wanted to do this was because I wanted to output only a subset of the 3-D array to a worksheet.

I was looking for a short-cut to something other than looping through (almost a bit like the resize command where you can output a 2-D array in one line of code to a worksheet).

I run monte-carlo simulations which are resource intensive and take a long time to complete so was just hoping for something which could cut down the processing time.

I think I'll stick with the looping...simplest solutions are often the best.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top