+ Reply to Thread
Results 1 to 9 of 9

Display contents of first occupied cell to the right - VLOOKUP?

  1. #1
    Registered User
    Join Date
    10-12-2016
    Location
    NY
    MS-Off Ver
    Professional Plus 2010
    Posts
    13

    Display contents of first occupied cell to the right - VLOOKUP?

    Hi y'all!

    In each row of my sheet, at least one cell in Columns B thru J contains data. I want the data from whichever is the first cell that is not blank to appear in column A. I think VLOOKUP is what I need, but I don't quite know how to make that work.

    Example: B1 is blank, C1 is blank, D1 has data, E1 has data. I want the data in D1 to appear in A1. Next row, B2 has data, C2 is blank, D2 has data, E2 is blank. I want the data from B2 to appear in B1.

    All data is text and ends in "WK".

    Is VLOOKUP the right thing to use? How do I need to write it?

    Thanks!!!

    kevin

  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: Display contents of first occupied cell to the right - VLOOKUP?

    Try this...

    Data Range
    A
    B
    C
    D
    E
    F
    1
    smip
    smip
    jurg
    2
    glorp
    glorp
    3
    plib
    plib
    blib
    4
    cronk
    cronk
    5
    ------
    ------
    ------
    ------
    ------
    ------


    Entered in A1 and copied down:

    =INDEX(B1:F1,MATCH("*",B1:F1,0))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    31,181

    Re: Display contents of first occupied cell to the right - VLOOKUP?

    Try

    =INDEX($B1:$J1,MATCH("*",$B1:$J1,0))

  4. #4
    Registered User
    Join Date
    10-12-2016
    Location
    NY
    MS-Off Ver
    Professional Plus 2010
    Posts
    13

    Re: Display contents of first occupied cell to the right - VLOOKUP?

    Using that formula, if B has data, it appears in A. If B is blank, A is blank. It's not continuing to look to the right until it finds something.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    31,181

    Re: Display contents of first occupied cell to the right - VLOOKUP?

    No it looks until finds first non-blank cell.

    See response #2 from Tony which shows the results you get.

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

    Re: Display contents of first occupied cell to the right - VLOOKUP?

    That makes it sound like the cells may have formulas and some of them return formula blanks "".

    Try this version:

    =INDEX(B1:F1,MATCH("?*",B1:F1,0))

  7. #7
    Registered User
    Join Date
    10-12-2016
    Location
    NY
    MS-Off Ver
    Professional Plus 2010
    Posts
    13

    Re: Display contents of first occupied cell to the right - VLOOKUP?

    My "blank" cells do seem to have something in them. I don't know why. My sheet is exported from SAP and I have to hit delete or clear contents to make things work right.

    But by using =INDEX(J2:P2,MATCH("*WK",J2:P2,0)) I got it to ignore whatever is in my "blank" cells and now it works.

    Thanks guys!!

    kevin
    2+2=#ERROR

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

    Re: Display contents of first occupied cell to the right - VLOOKUP?

    Good deal. Thanks for the feedback!

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

    Re: Display contents of first occupied cell to the right - VLOOKUP?

    Here's another option:

    =INDEX(B1:F1,MATCH(TRUE,INDEX((B1:F1<>0),0),0))
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

+ 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: 3
    Last Post: 06-29-2015, 03:03 PM
  2. [SOLVED] And formula, can it display contents of a cell?
    By KLG519 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-01-2014, 11:53 AM
  3. Display contents of cell in another only when clicked on
    By jshaw82 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-20-2013, 03:56 PM
  4. Making a cell display something other than its contents?
    By janschepens in forum Excel General
    Replies: 1
    Last Post: 08-21-2011, 12:27 PM
  5. Display contents of cell as variable?
    By Lovebaby in forum Excel General
    Replies: 2
    Last Post: 07-10-2006, 03:29 AM
  6. how do I display cell contents when I am over 32, 767 characters?
    By usdrmd in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 11-21-2005, 06:55 PM
  7. display contents of cell
    By Joseph in forum Excel General
    Replies: 0
    Last Post: 10-07-2005, 07:05 PM

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