Excel VBA changes the date format to mm / dd / yyyy

0

I'm developing a spreadsheet in Excel using VBA , which will function as a "micro-system" of registration.

I'm having the following problem: Every time I type the date in the cell Cad_0 , for example, Excel changes the format to mm/dd/yyyy .

On the same worksheet I'm already using a code so that Excel changes the typed text in lowercase to uppercase.

If I delete this code, Excel stops changing the date format.

    
asked by anonymous 09.10.2018 / 16:23

1 answer

0

Follow the template below, converting dates:

DimCDataAsDateDimCData2AsDate{'---MODELO01}SubDataCompra1()[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

    End If

End Sub

{'--- MODELO 02}  
Sub DataCompra2()  

    Dim CData As Date
    Dim CHora As Date

    dt = [C8].Value
    'fmt = [C8].Value
    CData = Format(dt)
    CHora = Format(Now)
    'Format (fmt)

    [E8].Value = CData
    [E9].Value = CHora

End Sub

Sub LimparData()

[C8].Value = ""
[E8].Value = ""

End Sub
    
19.10.2018 / 19:27