+ Reply to Thread
Results 1 to 10 of 10

Index Match within a table

  1. #1
    Registered User
    Join Date
    02-28-2019
    Location
    Canada
    MS-Off Ver
    office 365 for business
    Posts
    17

    Index Match within a table

    Greetings All,

    I am going to this as a last resort. Most of the time google helps me out.

    So, I am trying to look up a value within a table using index/match via vba code. The table may move around, or expand, so i want the table range to be dynamic.

    I am selecting a Purchase Order code in the list textbox and I want another textbox to display a description of that code. I have a table of PO CODES/DESCRIPTIONS somewhere in the workbook that I want to pull the info from.

    This is what I am trying to do:

    Please Login or Register  to view this content.
    I have tried to just indicate the static range, and it still gives me 1004. Not sure what to do here anymore. Could anyone provide a working example of a code that does index/match from a table?

    Thank you.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Index Match within a table

    Hello Sergey1989,

    You need to change MatchResult from a String type to a Long Type. Match returns the row number within the range when successful.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-28-2019
    Location
    Canada
    MS-Off Ver
    office 365 for business
    Posts
    17

    Re: Index Match within a table

    I really wish I could say it worked, but I am still having same error 1004 on the same line. TableRangeCodes is correctly identifies the range that I want to look at as $D$3:$D$8 when I use "msgbox TableRangeCodes.address". Could there be a syntax error in how I reference the range?

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Index Match within a table

    Is MatchResult number or string.
    If it is string, then use " .find"
    Last edited by PCI; 01-26-2020 at 06:09 AM. Reason: Typo
    - Battle without fear gives no glory - Just try

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Quote Originally Posted by Sergey1989 View Post
    Could there be a syntax error in how I reference the range?
    Hi,

    yes 'cause of

    • you forgot to declare the type of the TableRangeCodes variable
      as you can check during the execution in the Locals VBE window …

    • As a ListColum object does not have a DataBodyRange property !
      Just open the VBA inner help of ListColumn object to see its existing properties …

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Index Match within a table

    Hello Sergey1989,

    Can you post a copy of the workbook for review?

  7. #7
    Registered User
    Join Date
    02-28-2019
    Location
    Canada
    MS-Off Ver
    office 365 for business
    Posts
    17

    Re: Index Match within a table

    you forgot to declare the type of the TableRangeCodes variable
    as you can check during the execution in the Locals VBE window …

    As a ListColum object does not have a DataBodyRange property !
    Just open the VBA inner help of ListColumn object to see its existing properties …
    I thought that I declared "TableRangeCodes" as range. I will try to look into that.

    Is MatchResult number or string.
    If it is string, then use " .find"
    MatchResult should be an integer, right? I am looking for row number after all. Could you post an example?

    Can you post a copy of the workbook for review?
    I have isolated this example and put it into test workbook. Enter numbers 1-6 in the first cell.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Index Match within a table

    Something which seems working

    Please Login or Register  to view this content.
    Last edited by PCI; 01-27-2020 at 11:37 AM.

  9. #9
    Registered User
    Join Date
    02-28-2019
    Location
    Canada
    MS-Off Ver
    office 365 for business
    Posts
    17

    Re: Index Match within a table

    Could you please explain what each argument in that find command means?

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Index Match within a table


+ 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. INDEX MATCH from table with multiple MATCH criteria
    By nostrum in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-30-2019, 11:41 AM
  2. [SOLVED] Index Match Match for a small table lookup
    By slvrbktom in forum Excel Formulas & Functions
    Replies: 23
    Last Post: 09-05-2018, 06:08 PM
  3. [SOLVED] Index/Match when the Match criteria is based on a second table
    By Plummet in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-10-2017, 01:02 PM
  4. Replies: 2
    Last Post: 12-18-2014, 09:52 AM
  5. [SOLVED] Index Match Match returning incorrect value from table
    By DaveBre in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-04-2014, 08:01 PM
  6. Replies: 3
    Last Post: 05-19-2014, 02:01 PM
  7. Index Match Match Formula DOESN'T WORK WITH TABLES/TABLE NAMES ??
    By Underling in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-04-2014, 09:01 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