+ Reply to Thread
Results 1 to 10 of 10

Bringing an index/match function over to vba

  1. #1
    Registered User
    Join Date
    07-05-2017
    Location
    Denver, CO
    MS-Off Ver
    2013
    Posts
    5

    Bringing an index/match function over to vba

    Hey everybody,

    I am currently trying to make an auto populating form using index/match and VBA. The form will function by referencing 2 sheets to populate 1 in the same workbook. A reference name will come from the 'acct settle' sheet and various fields will be pulled from 'synd data' sheet to fill 'wire form' throughout a loop(hense VBA).

    My working function in cell is =INDEX('Synd Data'!I$2$:I$20$,MATCH('acct settle'!A6,'Synd Data'!B2:B5,0))

    Now my problem here is transferring this function into VBA terms. Here is my best attempt

    WorksheetFunction.Index(Worksheets("Synd Data").Range("I$2$:I$20$"), _
    WorksheetFunction.Match(Worksheets("Acct settle").Range("B15"), _
    Worksheets("Synd Data").Range("B$2$:B$5$"), 0))

    I know this is jumping around all over the place between sheets and I think that is the reason for my 1004 run time error. I have also attempted using just Application.Match and Application.worksheetFunction.Match. So my big question is if this is even possible and how I could get this to return a value to a cell regardless of a string or int. Thanks for any help in advance, I know this is a hot mess.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Bringing an index/match function over to vba

    It would help if you upload sample workbook.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    07-05-2017
    Location
    Denver, CO
    MS-Off Ver
    2013
    Posts
    5

    Re: Bringing an index/match function over to vba

    CK76,

    Here is the current book I am working on, the first sheet contains all the fields I will need to be pulling through the VBA loop.
    Attached Files Attached Files

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Bringing an index/match function over to vba

    Hmm, so what field in "Wire Form" sheet should be manually updated to fill the rest?

    Or if it's not "Wire Form" sheet, then what other field controls what to look up?

  5. #5
    Registered User
    Join Date
    07-05-2017
    Location
    Denver, CO
    MS-Off Ver
    2013
    Posts
    5

    Re: Bringing an index/match function over to vba

    The wire form will have a couple of manual entry cells, but the information being populated on the sheet is taken from 'Synd Data' (actual data to be put on sheet) and 'Acct settle' (used to indicated which data from 'Synd Data' to pull)

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Bringing an index/match function over to vba

    That's the confusing part for me. Shouldn't all controls reside in "Wire Form"?

    With current formula set up I see that 'acct settle'!A6 is used as Lookup Value. However, need to understand what logic is used to pick that as LookUp value over others.
    Otherwise, code would not be dynamic.

  7. #7
    Registered User
    Join Date
    07-05-2017
    Location
    Denver, CO
    MS-Off Ver
    2013
    Posts
    5

    Re: Bringing an index/match function over to vba

    Ideally, the code would check in cell 'acct settle'!A6 to see which bank is being referenced. Then it would check the 'Synd Data' sheet to pull things like acct # and ABA# which would be the values that populate the 'wire form'. From there it would save, print and loop down to cell A7 and so on until the A column displays an empty cell. And I am comfortable with that part, but for some reason the index/match function is giving me a lot of trouble.

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Bringing an index/match function over to vba

    Typically I don't use INDEX/MATCH worksheet function within VBA.

    I'd do it like below. See if this works for you.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-05-2017
    Location
    Denver, CO
    MS-Off Ver
    2013
    Posts
    5

    Re: Bringing an index/match function over to vba

    You are a life saver, worked like a charm! I have not seen this method used before, very interesting. I was thinking about it earlier today and landed on the same conclusion that index/match wasn't the best option to try to transfer over to VBA but didn't know any alternatives. Thanks again!

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Bringing an index/match function over to vba

    You are 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. Need help in Index, Match usage to match multiple criteria in sum function
    By Summer0830 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-26-2017, 02:47 AM
  2. Problems applying INDEX-MATCH-MATCH function on other data
    By LennartB in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-13-2015, 05:33 AM
  3. function INDEX MATCH MATCH doesn´t work
    By leonelcd in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-31-2015, 11:36 AM
  4. [SOLVED] Stuck on Match function with #N/A; attempting to reverse Index/Match
    By Cappytano in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-10-2014, 06:39 PM
  5. Replies: 6
    Last Post: 03-17-2014, 08:10 PM
  6. Replies: 3
    Last Post: 06-17-2013, 12:37 PM
  7. [SOLVED] INDEX MATCH formula bringing back incorrect data
    By Malinky in forum Excel General
    Replies: 2
    Last Post: 06-27-2012, 08:27 AM

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