+ Reply to Thread
Results 1 to 9 of 9

Variable column for VLookup possible?

  1. #1
    Registered User
    Join Date
    05-17-2020
    Location
    Heiloo, Nederland
    MS-Off Ver
    2007
    Posts
    32

    Question Variable column for VLookup possible?

    Good day to all,

    I am pretty sure it's possible, but somehow I can't get it working. Should probably be something with '(column())' or something like that.

    What am I talking about? Well, I am trying to find a formula with VLookup that, every time I copy the formula to the right the search will be in another column, too (also one to the right).

    This is the basic formula I got: IFERROR((VLOOKUP($C5;Sheet1!$C$5:H$5000;6)*H$4);"-")
    I underlined the '6', because I know that's the one number that should be changing. When I copy the formula one column right, the result would (should) be: IFERROR((VLOOKUP($C5;Sheet1!$C$5:I$5000;7)*H$4);"-")
    It's just that I'm talking about over 500 columns, may be even 1,000 at the moment, and I have no wish to re-enter the formula every time. So, is there a way to auto-change this (for example by using 'row()' of 'column()')?
    See attachment.

    Many thanks in advance!
    Attached Files Attached Files
    Thank you for your helpful answer.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,809

    Re: Variable column for VLookup possible?

    I think this is what you mean. In F5 copied across and down:

    =INDEX(Sheet1!$F$5:$H$30,MATCH($A5&$B5,Sheet1!$A$5:$A$30&Sheet1!$B$5:$B$30,0),MATCH(F$2,Sheet1!$F$2:$H$2,0))

    You will need to change commas to semi-colons for your Dutch locale.

    Add your IFERROR function as required.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    05-17-2020
    Location
    Heiloo, Nederland
    MS-Off Ver
    2007
    Posts
    32

    Re: Variable column for VLookup possible?

    If you unhide column C, you'll see that I put in there a small formula (= A4&", "&B5). Just needed that in all my tabs for other VLookup (I'm talking about a 2,000MB file here).

    Sadly, this gives me a #VALUE...
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,809

    Re: Variable column for VLookup possible?

    OK - did you really think I was going to hunt for hidden columns???

    I'll have another look, but it would help ENORMOUSLY if you would mock up the results you want instead of showing us something that isn't what you want ...

    This is what you want:

    =INDEX(Sheet1!$F$5:$H$30,MATCH($C5,Sheet1!$C$5:$C$30,0),MATCH(F$2,Sheet1!$F$2:$H$2,0))

    I think ...
    Last edited by AliGW; 02-11-2022 at 07:05 AM.

  5. #5
    Registered User
    Join Date
    05-17-2020
    Location
    Heiloo, Nederland
    MS-Off Ver
    2007
    Posts
    32

    Re: Variable column for VLookup possible?

    The result I want is in Sheet2 of my original added file... So, I am sorry, but I don't get why you give me that remark - no offence meant. I have no idea how to be more clear in my question, though. I really thought I wrote what I do want, and that is the result shown in Sheet2 of the original uploaded file.

    "MATCH" is not going to work. I do not wish to copy the contents. As you can see in the original file, I am multiplying the result (if possible, hence then "IFERROR") with the length of the circuit (row 4 in Sheet2). Sadly, that ain't working, apparently, with "MATCH".
    Last edited by AliGW; 02-11-2022 at 07:40 AM. Reason: PLEASE don't quote unnecessarily!

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,809

    Re: Variable column for VLookup possible?

    No offence taken.

    I am sorry - I don't get what you are looking for.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,809

    Re: Variable column for VLookup possible?

    Last try. In F5 copied across and down:

    =IFERROR(INDEX(Sheet1!$F$5:$H$30,MATCH($C5,Sheet1!$C$5:$C$30,0),MATCH(F$2,Sheet1!$F$2:$H$2,0))*F$4,"-")

  8. #8
    Registered User
    Join Date
    05-17-2020
    Location
    Heiloo, Nederland
    MS-Off Ver
    2007
    Posts
    32

    Re: Variable column for VLookup possible?

    Tnx, that seems to be working. Thank you.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,809

    Re: Variable column for VLookup possible?

    Great!

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

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

    Administrative Note:

    Members will tailor the solutions they offer to the version of Office (Excel) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your version is for Mac, please also state this. Thanks.

+ 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. Replies: 6
    Last Post: 09-30-2020, 09:42 PM
  2. [SOLVED] VLOOKUP with variable column index
    By vostroxe in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-26-2019, 04:36 PM
  3. [SOLVED] Variable for column index for Vlookup in vba
    By Richavlaues in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-06-2016, 10:33 AM
  4. VLookup with Variable Column Formula
    By Nlich in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-15-2014, 12:29 AM
  5. VBA: Variable column in Vlookup
    By TheDude76 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-27-2012, 03:48 PM
  6. Macro to write Vlookup formula with variable column index
    By Ashali in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-08-2012, 09:40 PM
  7. vlookup with variable column
    By dperry in forum Excel General
    Replies: 2
    Last Post: 08-15-2011, 09:42 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