I need some advice to rectify the code below. I have this code to copy paste lines to another sheet for data compilation purpose. And I'm running well using the with statement below, the problem is, when there's no data to paste, I do not know how to end the code with message box. I see the similar question above, how to comply the code into the With statement of VBA below? Following is the code I read from other user, to return message box if error. {If Err Then MsgBox "Nothing to paste!" Err.Clear End If}.
Or should I change the coding? If so, what is the correct coding to apply?
My original code, without the Message box return.
Or should I change the coding? If so, what is the correct coding to apply?
My original code, without the Message box return.
VBA Code:
[/
Sub FnLstRow()
Application.ScreenUpdating = False
Dim LR As Long
ThisWorkbook.Worksheets("Data").Select
LR = Cells(Rows.Count, "AO").End(xlUp).Row
Cells(LR, 1).Offset(1, 0).EntireRow.Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
With Sheets("LatestData")
.Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
End With
Application.CutCopyMode = False
Range("A1").Select
Application.ScreenUpdating = True
End Sub
]