+ Reply to Thread
Results 1 to 8 of 8

Using VLookup and offset to fill columns

  1. #1
    Registered User
    Join Date
    09-23-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    5

    Question Using VLookup and offset to fill columns

    Hope someone could help, I thought I had this but …

    I have 2 columns: Part# and Code#. The Part# can have up to 30 code# s attributed. I need to go down list and pull all code#s for each different part# and place code in a columns (Code1, Code2, Code 3, etc).

    Example:

    Part# Code#


    1234A AAAF
    1234A AAFF
    1234A AFFF
    6789X ZZZA
    6789X ZZAA
    8777N PPPP
    8777N PPPX
    8777N PPXX
    8777N PXXX
    8777N XXXX

    [B/]Need to populate codes across columns:[/B}

    Part# Code1 Code2 Code3 Code4 Code5 etc.
    1234A AAAF AAFF AFFF FFFF
    6789X ZZZA ZZAA
    8777N PPPP PPPX PPXX PXXXX XXXXX

    I tried this:

    =Offset(VLOOKUP(IF($A2=$A2,$A2,OFFSET($A2,1,0)),Code,2,FALSE),0,1)

    I think I going in the right direction but not there. I’d appreciate any help, thanks!
    ~Gr8tDaze!

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Using VLookup and offset to fill columns

    Try this...


    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    1
    2
    1234A
    AAAF
    1234A
    AAAF
    AAFF
    AFFF
    3
    1234A
    AAFF
    6789X
    ZZZA
    ZZAA
    4
    1234A
    AFFF
    8777N
    PPPP
    PPPX
    PPXX
    PXXX
    XXXX
    5
    6789X
    ZZZA
    6
    6789X
    ZZAA
    7
    8777N
    PPPP
    8
    8777N
    PPPX
    9
    8777N
    PPXX
    10
    8777N
    PXXX
    11
    8777N
    XXXX


    Enter this formula in E2:

    =IF(COLUMNS($E2:E2)>COUNTIF($A$2:$A$11,$D2),"",INDEX($B$2:$B$11,MATCH($D2,$A$2:$A$11,0)+COLUMNS($E2:E2)-1))

    Copy down as needed then across until you get a column full of blanks.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Using VLookup and offset to fill columns

    Hi Gr8tDaze and welcome to the forum

    Please see attached file.
    Attached Files Attached Files
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  4. #4
    Registered User
    Join Date
    09-23-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Using VLookup and offset to fill columns

    Hi AlKey,

    Thank you soooo much AlKey. Regret the long delay to respond (pulled to another project). Your code works great. My issue is trying to get code calculated through 170K records. Having very difficult time as system freezes up. Do you think there would be better performance with a pivot table or vba code? (Again, sorry for the late thank you).

  5. #5
    Registered User
    Join Date
    09-23-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Using VLookup and offset to fill columns

    Thanks Tony! Sorry for the delay in response I go pulled to another project. For some reason I could not get this code to work but was able to use AlKey's code below. Now having problem getting this to work for doing calculation on 170K rows ... Excel freezes. Is this too complex for a pivot table or would I get better performance with vba? (I asked the same question in response to AlKey .. I hope I'm not duplicating efforts)

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Using VLookup and offset to fill columns

    Gr8tDaze,

    I really don't know if the Pivot table or VBA solution will perform faster than formulas. 170k of date is a lot. The system freeze may have to to with your system resources. Sorry if I couldn't provide a better answer.

  7. #7
    Registered User
    Join Date
    09-23-2013
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Using VLookup and offset to fill columns

    Thanks again AlKey ... assumed problem with systems resources. I really appreciate your help with this.

  8. #8
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Using VLookup and offset to fill columns

    You're Welcome. Don't forget to thank those who helped by clicking on Add Reputation * and please mark thread as "Solved" if your issue has been resolved. (Selecting Thread Tools-> Mark thread as Solved).

+ 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: 5
    Last Post: 11-08-2012, 01:18 AM
  2. [SOLVED] How to offset a vlookup query by x columns to the left
    By datthed in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-29-2012, 01:25 PM
  3. [SOLVED] How to offset a vlookup tabe array by x columns
    By trilliansounds in forum Excel General
    Replies: 3
    Last Post: 03-28-2012, 09:27 AM
  4. Offset and fill
    By duskdrums in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-18-2006, 08:58 PM
  5. Vlookup/match/offset over multiple columns of lable
    By csw78 in forum Excel General
    Replies: 6
    Last Post: 06-08-2005, 11:39 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