+ Reply to Thread
Results 1 to 10 of 10

How to find first and last non empty cell in row and highlight between?

  1. #1
    Registered User
    Join Date
    01-26-2013
    Location
    IN,US
    MS-Off Ver
    2007
    Posts
    2

    How to find first and last non empty cell in row and highlight between?

    Good afternoon. I am trying to figure out how to find the first and last non empty cells and then color all cells in that row between/including those two cells. If there is only one value in the row I would want to just highlight that one cell. I would like to do this for all rows until the first blank row. I would like to do this for every row starting from D6:AG6 until the last non empty row. Any help/suggestions would be greatly appreciated.
    Last edited by Puzzles; 01-27-2013 at 11:15 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,484

    Re: How to find first and last non empty cell in row and highlight between?

    Something like:

    Please Login or Register  to view this content.

    It needs data in column D to determine how many rows to process. Pick a column that will have data in the last row.


    Regards, TMS



    Edit: amended as per jolivanes observation in post #3
    Last edited by TMS; 01-27-2013 at 12:29 PM. Reason: amended code
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,531

    Re: How to find first and last non empty cell in row and highlight between?

    Is this what you have in mind?


    Please Login or Register  to view this content.
    @TMShucks

    Should that not be

    Please Login or Register  to view this content.
    Last edited by jolivanes; 01-26-2013 at 07:20 PM.

  4. #4
    Registered User
    Join Date
    01-26-2013
    Location
    IN,US
    MS-Off Ver
    2007
    Posts
    2

    Re: How to find first and last non empty cell in row and highlight between?

    TMShucks that was my error, which is why I repost what I do. I thought I had to have a value in D to run it effectively. Thank you so much and have a wonderful rest of the weekend!

    Jolivanes thank you also for your help and have a wonderful rest of the weekend!

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,484

    Re: How to find first and last non empty cell in row and highlight between?

    @jolivanes: you are absolutely right ... that was an oversight. Thank you for picking it up. And I even tested it twice: I moved the data to column B so that I could test your code alongside mine. And do you know why it worked? Because my test data had row numbers in the cells from D6 to D15 and, subsequently, B6 to B15. So, in each case, that line of code still picked up 15, which was the last row of data. Just goes to show how two wrongs *can* make a right

    @Puzzles: thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,531

    Re: How to find first and last non empty cell in row and highlight between?

    @ Trevor
    I only found out because I tried both codes.

    Regards
    John

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,531

    Re: How to find first and last non empty cell in row and highlight between?

    Depending on your sheet setup but maybe this even works for you.

    Please Login or Register  to view this content.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,484

    Re: How to find first and last non empty cell in row and highlight between?

    @jolivanes: the latest version works but includes the data in column B which, I think, should be excluded.

    Regards, TMS

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,531

    Re: How to find first and last non empty cell in row and highlight between?

    Good morning (here anyway) Trevor.
    Yes, absolutely. Hence my "Depending on your sheet setup" remark.
    If there is anything in the Column to the left, it won't work as it's meant to by the OP.
    Have a great weekend.

    John

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,484

    Re: How to find first and last non empty cell in row and highlight between?

    @jolivanes: Sunday evening here ... too late to wish you a good weekend, so have a good week.

    Cheers

+ Reply to 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