+ Reply to Thread
Results 1 to 8 of 8

Get and use cell reference from a two-dimensional lookup

  1. #1
    Registered User
    Join Date
    08-19-2014
    Location
    San Francisco Bay Area, California
    MS-Off Ver
    Excel 2010
    Posts
    13

    Get and use cell reference from a two-dimensional lookup

    Context: manufacturing plant

    User input: On sheet Incidents, the user will enter events that disrupt production. The Incidents sheet has headers in Row 1 for various columns. Two of the columns (B & E) capture Production Run Number and Work Station Name.

    Macro output: The goal of the macro is to populate a blank grid on a 2nd sheet (let’s call it Summarize) used to summarize the results to support making a Pareto chart. The blank grid is framed, if you will, by the Production Run Numbers in Column B and the Work Station Names in Row 20. So the upper left cell of the blank grid starts in C21.

    The need: Code to go through each row on the Incidents sheet, use the Production Run Number and Work Station Name entries in Columns B & E to find the one corresponding cell reference on the Summarize sheet and populate it with information.

    What I’ve looked at:
    - A two-dimensional lookup returns the value of the found cell, but these cells will initially be blank and I want to populate them.
    - I believe using SUMPRODUCT (a variant of a two-dimensional lookup) requires the grid to already be populated with cell values.
    - Index Match seems to provide the cell value, whereas I’m thinking I need a cell reference to populate row and column variables to use in a For Next loop as the macro goes through the rows on the Incidents sheet.
    - Using a formula such as =ADDRESS(MATCH(‘Incidents'!B7,’Summarize‘!B21:B40,0),MATCH(Incidents'!E7, ’Summarize‘!C20:P20,0)) returns an address such as $A$1, which only means the relative address within the blank array (so “$A$1” is really C21 on the sheet).

    What VBA coding will fill the need, please? (I'm using Excel 2010.)


    Many thanks in advance!

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Get and use cell reference from a two-dimensional lookup

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    08-19-2014
    Location
    San Francisco Bay Area, California
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Get and use cell reference from a two-dimensional lookup

    Example file uploaded, with before and after! Thanks

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Get and use cell reference from a two-dimensional lookup

    Hi JOATrades,

    This relies upon the summary fields being as shown:

    Please Login or Register  to view this content.
    Directions for running the routine(s) just supplied

    If you haven't used macros before you'll need to go to:
    File- options - trust center -trust center settings - macro settings ,
    the second option down (disable all macros with notification)

    Then - Copy the code to the clipboard

    Open your Workbook

    Press ALT + F11 to open the Visual Basic Editor.

    Select "Module" from the Insert menu

    Type "Option Explicit" then paste the code under it

    With the cursor between Sub and End Sub press F5 (F8 to Single Step)

    OR

    Press ALT + Q to close the code window.

    Press ALT + F8 then double click on the macro name
    *Be sure to save the book with the code as Macro-Enabled
    Last edited by xladept; 09-11-2015 at 04:39 PM.

  5. #5
    Registered User
    Join Date
    08-19-2014
    Location
    San Francisco Bay Area, California
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Get and use cell reference from a two-dimensional lookup

    Thank you very much! It works like a charm.

    Now I just have to crawl through it to figure out exactly how it works so I can add to it. Each populated cell on sheet Summarize - Before will get 2 additional attributes based on the entries on sheet Incidents: a fill color depending on the corresponding Cause Type entered in Col D, and a comment containing the corresponding text in Col F.

    Appreciate the rapid solution, and my apologies for not responding sooner (I was out of pocket Friday afternoon until now).

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Get and use cell reference from a two-dimensional lookup

    You're welcome and thanks for the rep!

    Notify me when you post your next thread and I may be able to help.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  7. #7
    Registered User
    Join Date
    08-19-2014
    Location
    San Francisco Bay Area, California
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Get and use cell reference from a two-dimensional lookup

    Thanks, I was wondering how to show the question was answered!

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Get and use cell reference from a two-dimensional lookup

    You're welcome!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Sum with Two Dimensional lookup
    By aunakhtar in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-30-2015, 09:52 PM
  2. Two dimensional lookup using text strings rather than cell references
    By belpal in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-02-2015, 06:34 AM
  3. [SOLVED] populate worksheet cell based on two dimensional lookup values of combobox
    By rain4uu in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-27-2014, 03:05 AM
  4. Find a column reference for a cell meeting 2-dimensional criteria
    By crazytalker90 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 09-06-2013, 10:28 AM
  5. 2 dimensional lookup
    By vamshi57 in forum Excel General
    Replies: 8
    Last Post: 01-09-2011, 07:11 AM
  6. Two Dimensional Lookup
    By Swastik Banerje in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-19-2009, 12:57 PM
  7. Two Dimensional Lookup and Cell replace
    By hard4me in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-03-2008, 05:09 PM

Tags for this Thread

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