Error de compilación no se ha definido sub o fuction

Escribo este código, para que me salga la fecha y hora automáticamente al ingresar un producto en la lista pero no me funciona, me sale error de compilación sub o fuction no definida :

Private Sub Worksheet_Change(ByVal Target As Range)
      If Target.Column = 5 And Target.Row > 6 Then
          If Len(Trin(Sheets("regisauto").Cells(Target.Row - 1, 5))) > 0 Then
              Sheets("regisauto").Cells(Target.Row, 6) = Now
          End If
      End If
End Sub

Luego cuando le doy ejecutar no me deja, me abre una ventana para que cree una macro, le pongo nombre a la macro, le doy ejecutar de nuevo y nada.

AUXILIO!

2 respuestas

Respuesta
1

Private Sub Worksheet_Change(ByVal Target As Range)
      If Target.Column = 5 And Target.Row > 6 Then
          If Len(Trim(Sheets("regisauto").Cells(Target.Row - 1, 5))) > 0 Then
              Sheets("regisauto").Cells(Target.Row, 6) = Now
          End If
      End If
End Sub

Respuesta
1

Te paso la macro actualizada

Private Sub Worksheet_Change(ByVal Target As Range)
'//Por Aortiz
   If Target.Column = 5 And Target.Row > 6 Then
          If Cells(Target.Row - 1, 5) > 0 Then
              Cells(Target.Row, 6) = Format(Now, "dd/mm/yyyy hh:mm:ss")
          End If
      End If
End Sub

valora para finalizar saludos!

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas