IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Appliquer Format Date "JJ/MM/AA" valeur retourner par une TextBox VBA [XL-2010]


Sujet :

Macros et VBA Excel

  1. #1
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Octobre 2014
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2014
    Messages : 32
    Par défaut Appliquer Format Date "JJ/MM/AA" valeur retourner par une TextBox VBA
    Bonjour,

    Jusqu'à présent quand je saisie une date du type "JJ/MM/AAAA" dans ma TextBox, la valeur qui est retournée dans la cellule se transforme au format anglosaxon "MM/JJ/AAAA". Comment faire pour que la valeur retournée par la TextBox soit au format français ?



    Merci de votre aide

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Février 2007
    Messages
    2 266
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 2 266
    Par défaut
    Bonjour,

    Essaie avec :
    eric

  3. #3
    Invité
    Invité(e)
    Par défaut
    bonjour,
    range("A1")=Format(me.textbox,"yyyy-mm-dd")

  4. #4
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Octobre 2014
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2014
    Messages : 32
    Par défaut
    Citation Envoyé par rdurupt Voir le message
    bonjour,
    range("A1")=Format(me.textbox,"yyyy-mm-dd")


    Bonjour Rdurupt,

    Etant novice en VBA j'aurais besoin d'une petite précision, où écrire ce code ? au niveau du userform après Private Sub TextBox1_Change() ou dans un module à part?

    Merci

  5. #5
    Invité
    Invité(e)
    Par défaut
    en lieu et place de ce qui existe déjà dans ton code pour renseigner ta cellule avec la valeur du TextBox!

    bien sur avec la bonne cellule et le bon TextBox!

  6. #6
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Octobre 2014
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2014
    Messages : 32
    Par défaut
    Voici le code de mon userform si cela peut aider:


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
     Private Sub UserForm_Initialize()
      Set f = Sheets("BDD")
      Set mondico = CreateObject("Scripting.Dictionary")
      For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
        mondico(C.Value) = ""
      Next C
      temp = mondico.keys
      Call Tri(temp, LBound(temp), UBound(temp))
      Me.ComboBox1.List = temp
    End Sub
    Private Sub ComboBox1_click()
      Me.ComboBox2.Clear
      Me.ComboBox3.Clear
      Me.ComboBox4.Clear
      Me.ComboBox5.Clear
      Set mondico = CreateObject("Scripting.Dictionary")
      For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
        If C = Me.ComboBox1 Then mondico(C.Offset(, 1).Value) = ""
      Next C
      temp = mondico.keys
      Call Tri(temp, LBound(temp), UBound(temp))
      Me.ComboBox2.List = temp
    End Sub
    Private Sub ComboBox2_click()
      Me.ComboBox3.Clear
      Me.ComboBox4.Clear
      Me.ComboBox5.Clear
      Set mondico = CreateObject("Scripting.Dictionary")
      For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
        If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 Then mondico(C.Offset(, 2).Value) = ""
      Next C
      temp = mondico.keys
      Call Tri(temp, LBound(temp), UBound(temp))
      Me.ComboBox3.List = temp
    End Sub
    Private Sub ComboBox3_click()
      Me.ComboBox4.Clear
      Me.ComboBox5.Clear
      Set mondico = CreateObject("Scripting.Dictionary")
      For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
        If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 And C.Offset(, 2).Value = Me.ComboBox3 Then mondico(C.Offset(, 3).Value) = ""
      Next C
      temp = mondico.keys
      Call Tri(temp, LBound(temp), UBound(temp))
      Me.ComboBox4.List = temp
    End Sub
    Private Sub ComboBox4_click()
      Me.ComboBox5.Clear
      Set mondico = CreateObject("Scripting.Dictionary")
      For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
        If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 And C.Offset(, 2).Value = Me.ComboBox3 And C.Offset(, 3).Value = Me.ComboBox4 Then mondico(C.Offset(, 4).Value) = ""
      Next C
      temp = mondico.keys
      Call Tri(temp, LBound(temp), UBound(temp))
      Me.ComboBox5.List = temp
    End Sub
    Sub Tri(a, gauc, droi) ' Quick sort
      ref = a((gauc + droi) \ 2)
      g = gauc: d = droi
      Do
        Do While a(g) < ref: g = g + 1: Loop
        Do While ref < a(d): d = d - 1: Loop
          If g <= d Then
            temp = a(g): a(g) = a(d): a(d) = temp
            g = g + 1: d = d - 1
          End If
        Loop While g <= d
        If g < droi Then Call Tri(a, g, droi)
        If gauc < d Then Call Tri(a, gauc, d)
    End Sub
     
    Private Sub CommandButton1_Click()
    Dim DerLig As Integer
    If TextBox2 = "" Then
        MsgBox "Merci de remplir le champ Déscription"
        Exit Sub
    End If
    With Worksheets("Saisie")
        DerLig = .Range("B" & Rows.Count).End(xlUp).Row + 1
        .Range("C" & DerLig).Value = ComboBox1.Value
        .Range("D" & DerLig).Value = ComboBox2.Value
        .Range("E" & DerLig).Value = ComboBox3.Value
        .Range("F" & DerLig).Value = ComboBox4.Value
        .Range("G" & DerLig).Value = ComboBox5.Value
        .Range("B" & DerLig).Value = ComboBox6.Value
        .Range("H" & DerLig).Value = TextBox1.Value
        .Range("J" & DerLig).Value = TextBox2.Value
        .Range("I" & DerLig).Value = TextBox3.Value
        .Range("K" & DerLig).Value = TextBox4.Value
     
    End With
     
    Unload UserForm1
     
    End Sub

  7. #7
    Invité
    Invité(e)
    Par défaut
    j'ai mis le mise en forme au hasard, à toi de corriger!
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    Private Sub CommandButton1_Click()
    Dim DerLig As Integer
    If TextBox2 = "" Then
        MsgBox "Merci de remplir le champ Déscription"
        Exit Sub
    End If
    With Worksheets("Saisie")
        DerLig = .Range("B" & Rows.Count).End(xlUp).Row + 1
        .Range("C" & DerLig).Value = ComboBox1.Value
        .Range("D" & DerLig).Value = ComboBox2.Value
        .Range("E" & DerLig).Value = ComboBox3.Value
        .Range("F" & DerLig).Value = ComboBox4.Value
        .Range("G" & DerLig).Value = ComboBox5.Value
        .Range("B" & DerLig).Value = ComboBox6.Value
        .Range("H" & DerLig).Value = TextBox1.Value
        .Range("J" & DerLig).Value = TextBox2.Value
        .Range("I" & DerLig).Value = TextBox3.Value
        .Range("K" & DerLig).Value = Format(TextBox4.Value, "yyyy-mm-dd")
     
    End With

  8. #8
    Membre très actif Avatar de lionel86500
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2013
    Messages
    144
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vienne (Poitou Charente)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2013
    Messages : 144
    Par défaut
    Bonjour

    J'ai été confronté au même problème
    voici la solution
    il faut considérer comme date anglosaxon

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    range(scell) = format(sdate, "MM/DD/YY")
    scell étant la position de ta cellule, exemple A1
    sdate étant la donnée date sous le format (JJMMAA)

    ta date dans la cellule sera en formais Français JJ/MM/AA

  9. #9
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Octobre 2014
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2014
    Messages : 32
    Par défaut
    Merci beaucoup pour vos réponses Rdurupt et Lionel, ça marche très bien.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2007] COMMENT APPLIQUER un format DATE dans un TextBox
    Par NICOLE 0075 dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 21/09/2013, 16h03
  2. Appliquer le format date après import xml
    Par Ledaf dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 09/05/2011, 11h04
  3. [XL-2010] Appliquer le format date après import xml
    Par tibey dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 03/05/2011, 00h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo