Hi,
My code can only be activated when I am on a specific sheet ("Data"), how do I enable the code to be activated on other sheet ("KMV-Merton").
Option Explicit
Private Const dmax = 250
Sub LatestDate()
'Find the last used row in a Column: column A in this example
Dim LastRow As Long
With Worksheets("Data")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).row
End With
'CopyPaste the value of recent trading day dates
With Worksheets("Data")
.Range(Cells((LastRow - dmax + 1), 1), Cells(LastRow, 1)).Copy
End With
With Worksheets("KMV-Merton")
.Cells(2, "H").PasteSpecial xlPasteValuesAndNumberFormats
End With
End Sub
Bookmarks