This is a code I just created for another user. Converting dates.
According to what I mentioned above, if I understood correctly you want the script to execute such a procedure, right? If positive try putting the command Exit Sub
(without quotes) where you want to stop the code. Follow the template below.
Look for this note in the script below to better understand: <----- este é o código que faz parar o script.
DimCDataAsDateDimCData2AsDateSubDataCompra1(){'---FORMATANDODATAMOD01}[C8].SelectCData=[C8].ValueIfCData="0" Then
MsgBox "INFORME A DATA"
'Exit Sub '--- ESTA FUNÇÃO PARA O SCRIPT, CASO QUEIRA UTILIZAR DESCOMENTE A LINHA
Else
ActiveCell.Value = ""
Selection.Offset(0, 2).Select
ActiveCell.Value = CData
Exit Sub '<----- ESTE É O CÓDIGO QUE FAZ PARAR O SCRIPT.
MsgBox CData
End If
End Sub
Sub DataCompra2()
{'--- FORMATANDO DATA MOD 02}
Dim CData As Date
Dim CHora As Date
dt = [C8].Value
CData = Format(dt)
CHora = Format(Now)
[E8].Value = CData
[E9].Value = CHora
End Sub
Sub LimparData()
[C8].Value = ""
[E8].Value = ""
End Sub