+ Reply to Thread
Results 1 to 4 of 4

multiple array reference with lookup combination

  1. #1
    Registered User
    Join Date
    07-22-2008
    Location
    Netherlands
    Posts
    3

    multiple array reference with lookup combination

    This is something I like to do without resorting to vba...

    I have a huge table which looks roughly like:
    Please Login or Register  to view this content.


    In this table I want to randomly (from 1 to 20) pick an item from each room i.e. "Kitchen" and "5" which should result in "Knife".

    -The random part is easy and done.
    -Usually you can use vlookup to find "5" in an ascending list
    However in order to do that you first need to 'restrict' the search to the "Kitchen" array--> vlookup(5;C5:D7;2)

    I did find a way to build a string of the kitchen array which results in "C5:D7"
    You can't however feed a string into a formula and I have no clue how 'convert' a string into a cell reference.

    So an answer to either (or both):
    -how can you convert a string into a reference?
    -is there a (another)way to find a random item in the kitchen?

    thanks in advance.

  2. #2
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    Wolph

    I think you need to look at your indexing - it seems a little random. I used one table as follows:

    Please Login or Register  to view this content.
    I then used the RANDBETWEEN function from the Analysis Pack add-in to generate random numbers 1-3 for Room, 1-4 for Shed, 1-3 for Kitchen, etc.

    Lastly I used VLOOKUPs in a nested IF statement to lookup both the room and then the item.

    Please Login or Register  to view this content.
    To make the logic easier to follow, I also made extensive use of named ranges.

    HTH

    Martin
    Attached Files Attached Files
    Martin Short

  3. #3
    Registered User
    Join Date
    07-22-2008
    Location
    Netherlands
    Posts
    3

    if llife was only that simple...

    Martin,

    Thanks for the input, but unfortunately your way off, rearranging the table is one of the things I cant do, for one, there are more columns:
    i.e
    Please Login or Register  to view this content.
    The other is that the indexing is NOT random, its a distribution of chance to find the item in the room, if you look at the table you notice that:
    - there is a 4 in 20 chance to find the screwdriver
    - there is a 4 in 20 chance to find the hammer
    - there is a 7 in 20 chance to find the pliers
    - there is a 6 in 20 chance to find the tacker

    so you're answer won't work.... thanks anyway.

  4. #4
    Registered User
    Join Date
    07-22-2008
    Location
    Netherlands
    Posts
    3

    I might have found something, but still curious to other input

    Well I have found a way to do it, but I'm still curious to alternatives.
    Give the table:
    Please Login or Register  to view this content.
    (yes the first row is empty and used in the formula!)

    the formula used in B16 (where the correct result is) is:
    Please Login or Register  to view this content.
    it was quite a hassle to figure that one out. Essentially: "OFFSET" is the key to this problem

+ 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