Find the last row and highlight it yellow
Results 1 to 8 of 8

Thread: Find the last row and highlight it yellow
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    May 2016
    Posts
    39
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Find the last row and highlight it yellow

    Hi, any help on this is greatly appreciated!

    I'm trying to find the last row with data and highlight it yellow. I started with finding the last row but don't know the rest Help!

    Sub HighlightLastRow()


    Dim LastRow As Long

    With Sheets("Sheet1")
    LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row

  2. #2
    Board Regular
    Join Date
    Mar 2014
    Posts
    719
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Find the last row and highlight it yellow

    How about

    Code:
    Cells(Rows.Count, 1).End(xlUp).Interior.ColorIndex = 27

  3. #3
    New Member
    Join Date
    May 2016
    Posts
    39
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Find the last row and highlight it yellow

    Hi, I tried that and it only highlighted the last cell in column A. I was hoping it would highlight the entire row. Or maybe a better way is, find data in the last row in column A and highlight the entire row?

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    25,439
    Post Thanks / Like
    Mentioned
    443 Post(s)
    Tagged
    45 Thread(s)

    Default Re: Find the last row and highlight it yellow

    How about
    Code:
    With Sheets("Sheet1")
       Lastrow = .Cells(.Rows.Count, 1).End(xlUp).Row
       .Rows(Lastrow).Interior.Color = 45678
    End With
    Or
    Code:
    Range("A" & Rows.Count).End(xlUp).EntireRow.Interior.Color = 45678
    Last edited by Fluff; Jun 12th, 2019 at 04:42 PM.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  5. #5
    MrExcel MVP Rick Rothstein's Avatar
    Join Date
    Apr 2011
    Location
    New Jersey, USA
    Posts
    34,964
    Post Thanks / Like
    Mentioned
    91 Post(s)
    Tagged
    33 Thread(s)

    Default Re: Find the last row and highlight it yellow

    Quote Originally Posted by tropics123 View Post
    Quote Originally Posted by billandrew View Post
    How about

    Code:
    Cells(Rows.Count, 1).End(xlUp).Interior.ColorIndex = 27
    Hi, I tried that and it only highlighted the last cell in column A. I was hoping it would highlight the entire row. Or maybe a better way is, find data in the last row in column A and highlight the entire row?
    How about modifying Bill's code line to this...
    Code:
    Cells(Rows.Count, 1).End(xlUp).EntireRow.Interior.ColorIndex = 27
    Rick's "mini" blog... http://www.excelfox.com/forum/f22/
    .
    Want to post a small screen shot? See Part B here.

  6. #6
    Board Regular
    Join Date
    Mar 2014
    Posts
    719
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Find the last row and highlight it yellow

    How many Rows of data do you have?

    You can add .resize(, 5) preceding the Interior.ColorIndex = 27

    Change the "5" for the amount if columns in your data.

  7. #7
    New Member
    Join Date
    May 2016
    Posts
    39
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Find the last row and highlight it yellow

    I used Rick's modified version of Bill's and it worked!! Thank you!
    Cells(Rows.Count, 1).End(xlUp).EntireRow.Interior.ColorIndex = 27!

    Not sure if I could ask more questions in the same thread or but here goes...
    Above the yellow highlighted row are many columns filled with data, and a lot of the columns have repeated headers. For example, there will be multiple columns with the header "Type" and "Credit". I need some more help with #2 &#3 below I greatly appreciate your help.

    1) Copy all data from columns A-L and paste it in the first empty cell in column A below the highlighted row. This one I can do the macro for.

    2) If header is "Type" (and may appear in multiple columns), put in word "Finance" in the same column directly below the yellow highlighted row and go all the down to match with the number of rows in column A (the word "Finance" can only start below the yellow row)

    3) Copy all amounts in columns with header "Credit" and change the amounts to a positive number. The header "Credit" might be in multiple columns but find them all, and paste it directly its respective column below the yellow highlighted row.
    Last edited by tropics123; Jun 12th, 2019 at 05:40 PM.

  8. #8
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    25,439
    Post Thanks / Like
    Mentioned
    443 Post(s)
    Tagged
    45 Thread(s)

    Default Re: Find the last row and highlight it yellow

    As this is now a completely different you will need to start a new thread.
    Thanks
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •