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 :

Probleme de recuperation de Texbox [XL-2007]


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Homme Profil pro
    retraite
    Inscrit en
    Avril 2010
    Messages
    325
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : Espagne

    Informations professionnelles :
    Activité : retraite
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2010
    Messages : 325
    Par défaut Probleme de recuperation de Texbox
    Bonjour
    J'ai le code suivant:
    Je recupere le texbox dans la feuille en cours, mais je n'arrive pas a le recuperer dans une autre feuille, je recupere bien le dtpicker.
    j'ai mis en rouge l'endroit ou le code ne fonctionne plus
    si quelqu'un peu me dire dans ce code, comment faire pour ne pas faire
    de .select, car j'ai encore la mauvaise habitude d'utilise ceci, mais je ne sais comment faire
    merci
    cris

    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
    Private Sub CommandButton1_Click()
    Dim Sh As Worksheet
    Dim i As Integer
     
    If Controls("Textbox1") = "" Then
       MsgBox "Vous devez ABSOLUMENT indiquer Un Nom !", vbExclamation, _
              "ERREUR ... Entrez un Nom SVP !"
       Controls("Textbox1").SetFocus
       Exit Sub
    End If
     
    Application.ScreenUpdating = False
    With Selection
       .HorizontalAlignment = xlCenter
       .VerticalAlignment = xlCenter
    End With
    Selection.Merge
    Selection = UserForm1.Textbox1
    Unload UserForm1
    With Selection.Interior
       .Color = 65535
    End With
    With Selection.Font
       .ColorIndex = xlAutomatic
       Selection.Font.Bold = True
    End With
    '#--------------------------------------------------
    For Each Sh In Worksheets(Array("janv", "fevr", "mars", "Avr", "Mai", "Juin", "Juil", "Aout", "Sept", "Oct", "Nov", "Dec"))
       With Sh
          For i = 9 To 73
             .Range("B" & i) = 0
             If .Range("C" & i).Interior.Color = 65535 Then .Range("B" & i) = .Range("B" & i) + 0.25
             If .Range("K" & i).Interior.Color = 65535 Then .Range("B" & i) = .Range("B" & i) + 0.25
             If .Range("R" & i).Interior.Color = 65535 Then .Range("B" & i) = .Range("B" & i) + 0.25
             If .Range("Y" & i).Interior.Color = 65535 Then .Range("B" & i) = .Range("B" & i) + 0.25
          Next i
       End With
    Next Sh
    Sheets("recap_clients").Select
        [B3] = UserForm1.Textbox1
        [C3] = UserForm1.DTPicker1.Value
      Rows("3:3").Select
      Selection.Insert Shift:=xlDown
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Avril 2007
    Messages
    89
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Avril 2007
    Messages : 89
    Par défaut
    Bonjour,

    Je pense que le souci vient de la ligne 19:
    (cf. http://silkyroad.developpez.com/VBA/UserForm/)

    Il serait préférable d'utiliser + Unload en fin de procédure.

    Bonne journée

  3. #3
    Expert confirmé Avatar de casefayere
    Homme Profil pro
    RETRAITE
    Inscrit en
    Décembre 2006
    Messages
    5 138
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 71
    Localisation : France, Ardennes (Champagne Ardenne)

    Informations professionnelles :
    Activité : RETRAITE
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 138
    Par défaut
    Bonjour le forum, cris,

    Une approche, attention à mes remarques

    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
    Private Sub CommandButton1_Click()
    Dim Sh As Worksheet
    Dim i As Integer
     
    If userform1.Textbox1 = "" Then 'remplacer par nom USF
       MsgBox "Vous devez ABSOLUMENT indiquer Un Nom !", vbExclamation, _
              "ERREUR ... Entrez un Nom SVP !"
       userform1.Textbox1.SetFocus 'remplacer par nom USF
       Exit Sub
    End If
     
    Application.ScreenUpdating = False
    With Selection 'si la selection est effective...
       .HorizontalAlignment = xlCenter
       .VerticalAlignment = xlCenter
        .Merge 'si la selection est effective...
        Selection = userform1.Textbox1 'si la selection est effective et n'est que sur 1 cellule
        .Interior.Color = 65535 'si la selection est effective... (je me répète)
        With .Font
            .ColorIndex = xlAutomatic
            .Bold = True
        End With
    End With
    '#--------------------------------------------------
    For Each Sh In Worksheets(Array("janv", "fevr", "mars", "Avr", "Mai", "Juin", "Juil", "Aout", "Sept", "Oct", "Nov", "Dec"))
       With Sh
          For i = 9 To 73
             .Range("B" & i) = 0
             If .Range("C" & i).Interior.Color = 65535 Then .Range("B" & i) = .Range("B" & i) + 0.25
             If .Range("K" & i).Interior.Color = 65535 Then .Range("B" & i) = .Range("B" & i) + 0.25
             If .Range("R" & i).Interior.Color = 65535 Then .Range("B" & i) = .Range("B" & i) + 0.25
             If .Range("Y" & i).Interior.Color = 65535 Then .Range("B" & i) = .Range("B" & i) + 0.25
          Next i
       End With
    Next Sh
    With Sheets("recap_clients")
        .Range("B3") = userform1.Textbox1
        .Range("C3") = userform1.DTPicker1.Value
        .Rows("3:3").Insert Shift:=xlDown
    End With
    Unload userform1
    Application.ScreenUpdating = True
    End Sub


    PS : j'avais oublié un "End With
    Cordialement,
    Dom
    _____________________________________________
    Vous êtes nouveau ? pour baliser votre code, cliquer sur cet exemple : Anomaly
    pensez à cliquer sur :resolu: si votre problème l'est
    Par contre, il est désagréable de voir une discussion résolue sans message final du demandeur (satisfaction, désarroi, remerciement, conclusion...)

  4. #4
    Membre éclairé
    Homme Profil pro
    retraite
    Inscrit en
    Avril 2010
    Messages
    325
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 69
    Localisation : Espagne

    Informations professionnelles :
    Activité : retraite
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2010
    Messages : 325
    Par défaut
    Merci dom
    j'ai tout note ce que tu me disait et ca fonctionne
    merci
    cris

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

Discussions similaires

  1. probleme pour recuperer le chemin du dossier courant
    Par HoB dans le forum API standards et tierces
    Réponses: 8
    Dernier message: 11/08/2007, 11h22
  2. [xml-xsl][debutant]probleme de recuperation d'url
    Par psychogore dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 19/04/2005, 17h09
  3. Réponses: 2
    Dernier message: 15/04/2005, 09h27
  4. [C#] Problème de récupération d'une procédure Oracle
    Par minnieBis dans le forum ASP.NET
    Réponses: 11
    Dernier message: 20/04/2004, 13h48
  5. TThread: probleme de recuperation du Handle
    Par code34 dans le forum Langage
    Réponses: 8
    Dernier message: 07/09/2003, 03h04

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