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 :

VBA Excel: Concaténation


Sujet :

Macros et VBA Excel

  1. #1
    Membre averti Avatar de pmboutteau
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2005
    Messages
    601
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Santé

    Informations forums :
    Inscription : Février 2005
    Messages : 601
    Points : 420
    Points
    420
    Par défaut VBA Excel: Concaténation
    Bonjour, j'ai un petit problème de concaténation.

    Il ne me prends pas toutes mes valeurs.

    Voici mon code:

    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
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    Sub Caunois()
    '
    ' Caunois Macro
    ' Macro enregistrée le 16/02/2006 par boutteau
    '
     
    '
        LeNom = ActiveWorkbook.Name
        Workbooks.Add
        ChDir "C:\Documents and Settings\boutteau\Bureau"
        ActiveWorkbook.SaveAs Filename:= _
            "C:\Documents and Settings\boutteau\Bureau\GrapheQualTTH.xls", FileFormat:= _
            xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
            , CreateBackup:=False
        ActiveCell.FormulaR1C1 = "NumCommande"
        Range("B1").Select
        Columns("A:A").ColumnWidth = 16
        Range("B1").Select
        ActiveCell.FormulaR1C1 = "Min/Max"
        Range("C1").Select
        ActiveCell.FormulaR1C1 = "Valeur "
        Range("D1").Select
        ActiveCell.FormulaR1C1 = ""
        Windows(LeNom).Activate
        Windows("GrapheQualTTH.xls").Activate
        ActiveCell.FormulaR1C1 = "Lot"
        Range("E1").Select
        ActiveCell.FormulaR1C1 = "Coulee"
        Range("F1").Select
        ActiveCell.FormulaR1C1 = "Test"
        Range("G1").Select
        ActiveCell.FormulaR1C1 = "Lot/Coulee/Test"
        Range("D2").Select
        Columns("G:G").ColumnWidth = 15.14
        Windows(LeNom).Activate
        Range("H11").Select
        Selection.Copy
        Windows("GrapheQualTTH.xls").Activate
        Range("A2").Select
        ActiveSheet.Paste
        Range("A2").Select
        Application.CutCopyMode = False
        With Selection.Font
            .Name = "Arial"
            .Size = 10
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
        End With
        Selection.Font.Bold = False
        Range("A1").Select
        Selection.Font.Bold = True
        Range("B1").Select
        Selection.Font.Bold = True
        Range("C1").Select
        Selection.Font.Bold = True
        Range("D1").Select
        Selection.Font.Bold = True
        Range("E1").Select
        Selection.Font.Bold = True
        Range("F1").Select
        Selection.Font.Bold = True
        Range("G1").Select
        Selection.Font.Bold = True
        Range("B2").Select
        Windows(LeNom).Activate
        Range("G17").Select
        Selection.Copy
        Windows("GrapheQualTTH.xls").Activate
        Range("B2").Select
        ActiveSheet.Paste
        Windows(LeNom).Activate
        Range("G18").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("GrapheQualTTH.xls").Activate
        Range("B3").Select
        ActiveSheet.Paste
        Range("B2:B3").Select
        Selection.Font.Bold = False
        Windows(LeNom).Activate
        Range("G20", [G20].End(xlDown)).Select
        Selection.Copy
        Windows("GrapheQualTTH.xls").Activate
        Range("C2").Select
        ActiveSheet.Paste
        Selection.Font.ColorIndex = 1
        Range("C2").Select
        With Selection
            .HorizontalAlignment = xlLeft
            .VerticalAlignment = xlBottom
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .MergeCells = False
        End With
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlBottom
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .ShrinkToFit = False
            .MergeCells = False
        End With
        Selection.Font.ColorIndex = 1
        Range("D2").Select
        Windows(LeNom).Activate
        Range("F20", [F20].End(xlDown)).Select
        Selection.Copy
        Windows("GrapheQualTTH.xls").Activate
        ActiveSheet.Paste
        Windows(LeNom).Activate
        Range("E20", [E20].End(xlDown)).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("GrapheQualTTH.xls").Activate
        Range("E2").Select
        ActiveSheet.Paste
        Windows("Fichier Type.xls").Activate
        Range("D20", [D20].End(xlDown)).Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("GrapheQualTTH.xls").Activate
        Range("F2").Select
        ActiveSheet.Paste
        Range("G2").Select
        Application.CutCopyMode = False
         Range("G2").Select
        ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-3],""/"",RC[-2],""/"",RC[-1])"
        Range("G2").Select
        Selection.AutoFill Destination:=Range("G2", [F2].End(xlDown)), Type:=xlFillDefault
        Range("G2", [F2].End(xlDown)).Select
     
    End Sub
    Je concatene D, E et F dans G. Je fais pour m'arrêter jusque la fin de F mais il ne le fait pas?

    J'ai essayé
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Selection.AutoFill Destination:=Range("G2", [F2].End(xlDown)), Type:=xlFillDefault
    çà marche pas et
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Selection.AutoFill Destination:=Range("G2", [G2].End(xlDown)), Type:=xlFillDefault
    là il remplit toute la colonne G de "//" en plus de mes valeurs?
    ours ours !! Au début elle est froide mais après elle est bonne!

  2. #2
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Points : 15 543
    Points
    15 543
    Par défaut
    Que ne prend-t-il pas ?
    Déjà, si tu simplifiais ton code, tu as deux select de trop en cinq lignes

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
        Range("G2").Select 
        Application.CutCopyMode = False  
        ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-3],""/"",RC[-2],""/"",RC[-1])" 
        Selection.AutoFill Destination:=Range("G2:G14"), Type:=xlFillDefault 
        Range("G2", [F2].End(xlDown)).Select
    A+

  3. #3
    Membre averti Avatar de pmboutteau
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2005
    Messages
    601
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Santé

    Informations forums :
    Inscription : Février 2005
    Messages : 601
    Points : 420
    Points
    420
    Par défaut
    En fait je n'y connais rien en Excel, on m'a demandé de faire une petite macro mais c'est pas du tout ma spécialité donc je bosse en créant le code automatiquement et je modifie dedans tant bien que mal donc je peux pas te renseigner. Désolé.

    Sinon il me prends bien mes valeurs mais ils ne s'arrêtent pas au bon endroit. Après il me remplit la colonne G de // jusque la ligne 66000 et quelques!
    ours ours !! Au début elle est froide mais après elle est bonne!

  4. #4
    Expert éminent sénior


    Profil pro
    Inscrit en
    Juin 2003
    Messages
    14 008
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 14 008
    Points : 20 038
    Points
    20 038
    Par défaut
    tiens essai :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Selection.AutoFill Destination:=Range("G2", [f2].End(xlDown).Offset(0, 1)), Type:=xlFillDefault

  5. #5
    Membre averti Avatar de pmboutteau
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2005
    Messages
    601
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Santé

    Informations forums :
    Inscription : Février 2005
    Messages : 601
    Points : 420
    Points
    420
    Par défaut
    çà fonctionne Nickel, merci beaucoup.
    ours ours !! Au début elle est froide mais après elle est bonne!

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

Discussions similaires

  1. Calcul max et concaténation dans VBA Excel
    Par pontoise dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 24/11/2008, 14h39
  2. VBA EXCEL : Concaténation des cellules d'une colonne
    Par kikaillo dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 09/07/2007, 17h37
  3. [VBA Excel] Pb de concaténation
    Par cedric59dk dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 29/01/2007, 09h15
  4. [VBA Excel] Pb concaténation
    Par cedric59dk dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 27/01/2007, 10h10
  5. [VBA-Excel]probleme concaténation (bis)
    Par Mugette dans le forum Macros et VBA Excel
    Réponses: 6
    Dernier message: 16/10/2006, 18h35

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