'Rosario Peña 13/04/18 Private Sub Worksheet_Change(ByVal Target As Range) Dim KeyCells As Range ' The variable KeyCells contains the cells that will ' cause an alert when they are changed. Set KeyCells = Range("B7") If Not Application.Intersect(KeyCells, Range(Target.Address)) _ Is Nothing Then ' Display a message when one of the designated cells has been ' changed. ' Place your code here. ' MsgBox "Cell " & Target.Address & " has changed." id_muestreo End If End Sub Sub id_muestreo() Dim fecha_Default As Date Dim fecha_Campo As Date fecha_Default = CDate("01/04/3000") fecha_Campo = Range("B7").Value If fecha_Default <> fecha_Campo Then If Range("M1").Value = "" Then Range("M1").Value = Application.WorksheetFunction.RandBetween(1000, 10000) 'MsgBox Application.WorksheetFunction.RandBetween(1000, 10000) End If End If End Sub