Closed Thread
Results 1 to 5 of 5

VLOOKUP -- automatically change col index

  1. #1
    Registered User
    Join Date
    10-25-2007
    Posts
    5

    VLOOKUP -- automatically change col index

    Hello All,

    Is there a way to automatically change the column index number in the VLOOKUP formula when copying the formula to columns? For example, when I copy a VLOOKUP formula from column A to column B, the cell references will change, but the column index remains the same. I'd like the column index to be increased by 1.

    Thanks!
    Last edited by VBA Noob; 11-19-2008 at 04:24 AM.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Assuming the first instance of the formula is in D2 then,rather than use a number for the column index, e.g. 2, use a function like

    COLUMNS(D$2:D2)+1

    when this is copied across to E2 it automatically increments.

    I prefer to use INDEX(MATCH type formulas here, then you can just make the references relative or fixed as you need, what's your current formula?

  3. #3
    Registered User
    Join Date
    10-25-2007
    Posts
    5

    Smile

    Hi, daddylonglegs,

    Thanks! I figured it out with your suggestion.

    My original formula: =VLOOKUP($J$1,$A$1:$D$6,2,FALSE)

    Modified formula: =VLOOKUP($J$1,$A$1:$D$6,COLUMNS($A$1:B6),FALSE)

    Now, when I copy the formula to the right, the relative cell reference in the COLUMNS formula updates to include the additional column(s).

    Last edited by ephilli2; 10-25-2007 at 01:35 PM.

  4. #4
    Registered User
    Join Date
    11-16-2010
    Location
    new york, ny
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: VLOOKUP -- automatically change col index

    Quote Originally Posted by ephilli2 View Post
    Hi, daddylonglegs,

    Thanks! I figured it out with your suggestion.

    My original formula: =VLOOKUP($J$1,$A$1:$D$6,2,FALSE)

    Modified formula: =VLOOKUP($J$1,$A$1:$D$6,COLUMNS($A$1:B6),FALSE)

    Now, when I copy the formula to the right, the relative cell reference in the COLUMNS formula updates to include the additional column(s).

    I was trying to figure this one out as I have data that is trying to divide one value on one spreadsheet from one value on another spreadsheet. So my formula has to look up the item # on my current to the same item number on the other spreadsheet then it has to go X(37) number of rows on the other workbook to the right once it finds that item # and then perform the equation. From there it moves one column to the right right after this.

    I could not find an equation for this was anyone able to figure it out?

    =(AZ4/(VLOOKUP($A4,'[Eligard Inserts Working Spreadsheet 11-16-10.xls]INSERTS'!$A$4:$AV$94,37,FALSE)))

    This pulls in the number from column 37and divides az4/(number from column 37 that matches to A4).

    This works on one cell but not when you copy and paste this to the right. My solution that I prefer not to use is:

    =(AZ4/(VLOOKUP($A4,'[Eligard Inserts Working Spreadsheet 11-16-10.xls]INSERTS'!$A$4:$AV$94,'[Eligard Inserts Working Spreadsheet 11-16-10.xls]INSERTS'!AK$1,FALSE)))

    What I did was make another row and on column37 in this blank row I wrote 37,38,39... Then this formula above returns a value of 37 and moves on. The above formula is a simplistic solution but is unrealistic when you have a larger spreadsheet. Does anyone have any ideas?

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VLOOKUP -- automatically change col index

    @bombadillio, welcome to the board but please note:

    Your post does not comply with Rule 2 of our Forum RULES.
    Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

Closed 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