+ Reply to Thread
Results 1 to 8 of 8

Multi-Dimensional Named Array

  1. #1
    Forum Contributor
    Join Date
    06-03-2008
    Posts
    387

    Multi-Dimensional Named Array

    I'd like to create an array like the following: Array[SKU][Color] will give me the code for a particular SKU in one particular color.

    I'm unfamiliar with the syntax for VBA arrays though, so any examples would be helpful.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485
    You create and use Arrays like this

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    If you don't need a multidimensional array, I would suggest that you don't use one. For your case, I would just use 2 arrays.

    e.g.
    Please Login or Register  to view this content.
    If you still want to use a 2 dimensional array, I can show that method if you like.

    Of course it would probably be better to create a sheet with the sku's in one column with the colors for the fonts or interior.color set as you like. You can then copy them as needed without using arrays.
    Last edited by Kenneth Hobson; 12-22-2008 at 11:26 AM.

  4. #4
    Forum Contributor
    Join Date
    06-03-2008
    Posts
    387
    I'm pretty sure I'll need a multidimensional array still.

    I've been looking at creating my own Type instead though.

    The problem is that I'll have data such as the SKU and Color, and I'll need to return several pieces of information based on that.

    It's a bit perplexing to me that you can only retrieve data from arrays using numbers, so I'll essentially be looping through an array until I find the SKU that I want, which seems like it will slow down the process a lot.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485
    If you want to index using names rather than numerical indices then you need to look at using a collection, which has a textual key.

  6. #6
    Forum Contributor
    Join Date
    06-03-2008
    Posts
    387
    So how do I create a multi-dimensional collection?

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485
    The collection would not be multi dimensional. But the objects it contained can be.

    You would need to create a class object that contains an array for the colours.

    You would then create and populate the collection with an object for each SKU. Filling in the colours as you go.

    If you need more information then provide us with more detail about sku's and colours associated with skus.

  8. #8
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    Use Match to search for a particular element in an array though iterating through the array is faster than you might think.

    e.g.
    Please Login or Register  to view this content.
    One can use the Dictionary object for such things but I wind up converting the keys or items to an array and use Match for your scenario anyway.
    Last edited by Kenneth Hobson; 12-22-2008 at 12:32 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1