+ Reply to Thread
Results 1 to 9 of 9

Look for the content of last non-empty cell in a range and provide a specific value

  1. #1
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    104

    Look for the content of last non-empty cell in a range and provide a specific value

    Hello,

    (I have google a fair bit to help me find an answer but was unsuccessful so I am looking for help.)

    I am looking for a formula that would look through a range of cells on a same row and find which one is the last cell of that range to have value in it (i.e. not blank) going horizontaly left to right. Once that is identified, depending on where that last cell was (it which column) it would provide a specific text value.

    Here a little more details:
    -The range for the first row would be from column C to column F (C1:F1) and the result of the formula would be in column G (G1)
    -If the first cell (C1) is the last cell in the C1 to F1 range to have value in it then the value entered in G1 would be ‘Step #1’;
    -If the 2nd cell (D1) is the last cell in the C1 to F1 range to have value in it then the value entered in G1 would be ‘Step #2’; and so on up to step #4
    -All value in the cells are text value.

    I have attaching an example to better illustrate what I am looking for. Thank you in advance for your time!
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Look for the content of last non-empty cell in a range and provide a specific value

    Im a little confused as to what you want here.

    If you want to return the text in the last-filled cell in the row...
    =INDEX(C1:Z1,MATCH("*",C1:Z1,-1))

    If you want to deterine how many cells contain data...
    ="Step #"&COUNTA(C1:F1)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    104

    Re: Look for the content of last non-empty cell in a range and provide a specific value

    Hello,

    Thank you for your quick response and sorry I was not clear enough. I am not looking for to return the text in the last-filled cell in the range nor to determine how many cells contain data. Did you have a change to look at the attached example in post #1 which may help?

    Let me try to explain in a slightly different way:
    I am looking for the formula to identified the last-filled cell in the range (For example C1:F1). Once that is done:
    if the last filled cell was in that range was in column C, then return the text value 'Step #1' in cell G1 or
    if the last filled cell was in that range was in column D, then return the text value 'Step #2' in cell G1 or
    if the last filled cell was in that range was in column E, then return the text value 'Step #3' in cell G1 or
    if the last filled cell was in that range was in column F, then return the text value 'Step #3' in cell G1

    I hope this clarify what I am looking for. Thank you!

  4. #4
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Look for the content of last non-empty cell in a range and provide a specific value

    Try

    ="Step #"&MAX(INDEX((C1:F1<>"")*(ROW(C1:F1)),0))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  5. #5
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    104

    Re: Look for the content of last non-empty cell in a range and provide a specific value

    Quote Originally Posted by Ace_XL View Post
    Try

    ="Step #"&MAX(INDEX((C1:F1<>"")*(ROW(C1:F1)),0))
    Thank you for your response. I tried it and it work for the first 4 rows but after that the formula did not work for the rest of the data that I added. It should not be higher than step #4 as there is only 4 column for the 'ranking' (column C,D,E &F). I have added another example workbook to show the results of your formula and the results that I expect.

    Thank you!
    Attached Files Attached Files

  6. #6
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Look for the content of last non-empty cell in a range and provide a specific value

    My bad..it should be

    ="Step #"&MAX(INDEX((C1:F1<>"")*(COLUMN(C1:F1)-COLUMN(C:C)+1),0))

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Look for the content of last non-empty cell in a range and provide a specific value

    Hello,

    Thank you for your quick response and sorry I was not clear enough. I am not looking for to return the text in the last-filled cell in the range nor to determine how many cells contain data. Did you have a change to look at the attached example in post #1 which may help?
    Thats exactly what my 2nd fformula does for you...

    C
    D
    E
    F
    G
    1
    abc Step #1
    2
    abc abc Step #2
    3
    abc acb abc Step #3
    4
    abc abc abc abc Step #4


    G1="Step #"&COUNTA(C1:F1) copied down

    So unless you have blank cells within your data (ie C4, C5=data, C6=blanl, C7=data), that will do what you need. If it is not working for you, please show me where it isnt working)

  8. #8
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    104

    Re: Look for the content of last non-empty cell in a range and provide a specific value

    Fdibbins: Terribly sorry, your 2nd formula does work, I should have tried it at the beginning but the title let me to believe the results would not be want I wanted but I was wrong.

    Ace_XL: You revised formula work as well. Thank you for your time!

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Look for the content of last non-empty cell in a range and provide a specific value

    Not a problem, it happens Im just glad we were able to resolve your questio, and thanks for the feedback

+ 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. [SOLVED] Find next empty cell (Row)within a specific range in column A
    By JRidge in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2014, 05:39 AM
  2. How to delete entire row if first cell of it is empty for specific range and worksheets
    By roshanvmech in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-01-2014, 12:36 PM
  3. [SOLVED] Select the last empty cell of the range specific
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-06-2013, 09:48 AM
  4. Macro to find next empty cell in specific range
    By boatbabe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2013, 09:18 AM

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