+ Reply to Thread
Results 1 to 4 of 4

general question :Multi-dimensional arrays

  1. #1
    Registered User
    Join Date
    08-12-2009
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    general question :Multi-dimensional arrays

    Hi,

    This is a general question about how it's possible to use arrays in VBA.

    What I am trying to do is use a 2 dimensional array to store the names of employees and their normal start time for work for each day of the week.

    Unless I'm mistaken then this should be possible by using an array as shown below:

    Please Login or Register  to view this content.
    What I want to do is define the first dimension as the name and the second dimension as the day and then be able to find the time for a specific employee on a specific day by matching their name and the day. This is where I am at a loss for what to do.

    I can load the data into the array one value at a time.

    Please Login or Register  to view this content.
    But this does not allow me to reference that time by the name or the day directly, only by their numerical order in the array.

    I hope this is not a stupid question, causing many to roll their eyes but I know I can make a significant advancement using arrays but need a little help to find my feet.

    If I've left any key details out or more info is needed please let me know.

    Thanks

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    re: general question :Multi-dimensional arrays

    Like this?
    Please Login or Register  to view this content.

    Or this:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    re: general question :Multi-dimensional arrays

    I'd tend to use a VLOOKUP table on a worksheet rather than hardcoding values. (Its easier to change and maintain.) But the VLOOKUP function can be used with arrays as well as ranges

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    08-12-2009
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    10

    re: general question :Multi-dimensional arrays

    Thanks. That's incredibily useful. I kept getting lost in the idea that the name had to be defined in the first variable rather than being the first entry i the second.

    Thanks!

+ 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