• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA to Find and locate last row updated in Excel

Dear Gurus,

Greetings.

Please share me the VBA to Find and locate last row updated in Excel.
I wish to highlight with "blue" colour the last row in Excel.

Thanks in advance.

Vignesh Veerasamy.
 
Change the Column Label in the lr = line to suit what column will definately have data in the last ro


Code:
Sub Color_Last_Row()
Dim lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
With Rows(lr).Interior
  .Pattern = xlSolid
  .PatternColorIndex = xlAutomatic
  .Color = 65535    'Yellow
End With

End Sub

If you don't know which Column will have data in the last row use:
Code:
Sub Color_Last_Row()
Dim lr As Long
lr = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
With Rows(lr).Interior
  .Pattern = xlSolid
  .PatternColorIndex = xlAutomatic
  .Color = 65535    'Yellow
End With

End Sub
 
Change the Column Label in the lr = line to suit what column will definately have data in the last ro


Code:
Sub Color_Last_Row()
Dim lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
With Rows(lr).Interior
  .Pattern = xlSolid
  .PatternColorIndex = xlAutomatic
  .Color = 65535    'Yellow
End With

End Sub

If you don't know which Column will have data in the last row use:
Code:
Sub Color_Last_Row()
Dim lr As Long
lr = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
With Rows(lr).Interior
  .Pattern = xlSolid
  .PatternColorIndex = xlAutomatic
  .Color = 65535    'Yellow
End With

End Sub
Dear Hui

Thanks for your swift response.
Macro is working with yellow highlight but excel is not showing me the exact row in which the data is available need to scroll down to the data,can I have such that macro takes to particular last row in last line.

Vignesh Veerasamy.
 
F
Add a line at the end
Rows(lr).select

Hi

Getting a pop up message Object doesnt support this property or method.Below is the code I use in Excel.

Code:
Sub Color_Last_Row()
Dim lr As Long
lr = Range("B" & Rows.Count).End(xlUp).Row
With Rows(lr).Interior
  .Pattern = xlSolid
  .PatternColorIndex = xlAutomatic
  .Color = 65535    'Yellow
  .Rows(lr).Select
End With

End Sub
Vignesh Veerasamy.
 
Last edited by a moderator:
F


Hi

Getting a pop up message Object doesnt support this property or method.Below is the code I use in Excel.

Sub Color_Last_Row()
Dim lr As Long
lr = Range("B" & Rows.Count).End(xlUp).Row
With Rows(lr).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535 'Yellow
.Rows(lr).Select
End With

End Sub

Vignesh Veerasamy.

Hi

Also colour required is other than Yellow.

Vignesh Veerasamy
 
Back
Top