+ Reply to Thread
Results 1 to 6 of 6

Vlookup in a macro for multiple ranges, Help?

  1. #1
    Forum Contributor
    Join Date
    12-01-2010
    Location
    Southampton, England
    MS-Off Ver
    Excel 2007
    Posts
    303

    Vlookup in a macro for multiple ranges, Help?

    Ok so im mediocre at using formulae but a slight amature when it comes to macros. I am feeling this needs a macro, although if it can be achieved via a formulae then great.

    I have attatched an exaple of the data i am interpreting, which outlines the problem.

    Essentially the aim is to input the Top data value of the rank 1 piece of data parrallel to every cell in each data set. In theroy i should be able to do it using some complicated formulae but i keep getting circular refernce.

    The reason i would like to be able to do it automatically is i can produce/recieve hundereds of these datasets.

    Any advice, or contribution would be greatly appreciated.

    Many thanks.
    Attached Files Attached Files

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Vlookup in a macro for multiple ranges, Help?

    Hi Ad,

    Delete the text from J9 (leave it blank), then put this array formula in J10 and fill it down the column as far as necessary. (After typing or pasting this formula into J10, you must press CTRL+SHIFT+ENTER, not just ENTER.) Also, change the references to $I$500 to a higher row number if your data goes further down than row 500.

    =IF(I10="","",IF(J9<>"",J9,INDEX(INDIRECT("I"&ROW()&":I"&ROW()+MATCH(TRUE,I10:$I$500="",0)-2),MATCH(1,INDIRECT("F"&ROW()&":F"&ROW()+MATCH(TRUE,I10:$I$500="",0)),0))))

    Hope that helps!

  3. #3
    Forum Contributor
    Join Date
    12-01-2010
    Location
    Southampton, England
    MS-Off Ver
    Excel 2007
    Posts
    303

    Re: Vlookup in a macro for multiple ranges, Help?

    Wow that is amazing! Ok im not sure whether this is the norm, but would it be possible to explain how this formuale works, so that in the future i do not need to refer to the forum for help, and might even be able to contribute more to helping others on this forum.

    As i said im not sure if this is normal practice or not, but i really need to learn about these array formulae, or even point me in the direction of where is best to learn about them.

    Anyways your reputation has jus been boosted many thanks Ad

  4. #4
    Forum Contributor
    Join Date
    12-01-2010
    Location
    Southampton, England
    MS-Off Ver
    Excel 2007
    Posts
    303

    Re: Vlookup in a macro for multiple ranges, Help?

    Ok im starting to understand it a little, have manged to successfully use it on my data however i failed to cover one scinario which can occur which leads this equation to not work for all datasets (a huge problem.)

    Please see attached spreadsheet it outlines the annomalie not covered by this array formula.

    Many thanks

    ad
    Attached Files Attached Files

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Vlookup in a macro for multiple ranges, Help?

    In the formulas in column I, currently:

    =IF(OR(ISNUMBER(B41),(ISNUMBER(C41)),(ISNUMBER(D41))),(LARGE(B41:D41,1)),(""))

    Can it be changed to:

    =IF(OR(ISNUMBER(B41),(ISNUMBER(C41)),(ISNUMBER(D41))),(LARGE(B41:D41,1)),0)

    This way a 0 will appear in column I instead of a blank, leaving blanks only where there is truly no data in previous columns (the blanks in between data sets). Unless you have data sets containing mostly negative numbers, 0 would never be returned as the #1 rank (just an assumption).

    If that can't be done, we can probably tweak the array formula I gave you to include another logic check.

  6. #6
    Forum Contributor
    Join Date
    12-01-2010
    Location
    Southampton, England
    MS-Off Ver
    Excel 2007
    Posts
    303

    Re: Vlookup in a macro for multiple ranges, Help?

    Ok yeh i changed the formula so it returned a "0" instead of "", it works perfectly now. Many 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