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 :

Macro de comparaison


Sujet :

Macros et VBA Excel

  1. #1
    Inactif
    Homme Profil pro
    Ingénieur développement matériel électronique
    Inscrit en
    Novembre 2011
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement matériel électronique
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Novembre 2011
    Messages : 4
    Par défaut Macro de comparaison
    Bonjour,

    Je souhaite mettre à jour une macro de comparaison qui fait la comparaison entre deux fichiers texte (.txt), sur ces deux fichiers texte nos données sont séparées par les deux points.
    Sur le résultat la macro ne me compare pas la deuxième donnée (M6,S1,M8) du fichier text1 avec le fichier text2.
    Fichiers attachés Fichiers attachés

  2. #2
    Expert confirmé
    Avatar de fring
    Homme Profil pro
    Engineering
    Inscrit en
    Février 2008
    Messages
    3 900
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : Belgique

    Informations professionnelles :
    Activité : Engineering

    Informations forums :
    Inscription : Février 2008
    Messages : 3 900
    Par défaut
    Bonjour,

    Pour espérer avoir une réponse il faudrait montrer le code

  3. #3
    Inactif
    Homme Profil pro
    Ingénieur développement matériel électronique
    Inscrit en
    Novembre 2011
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement matériel électronique
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Novembre 2011
    Messages : 4
    Par défaut
    Bonjour,

    Ci-joint le code, ainsi une partie du résultat du compare.
    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
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    Sub Extraire_Harness_Wire_Specification()
        'Ajout d'une feuille excel et la nommer "Harness wire specification"
        Sheets(1).Select
        Sheets.Add
        ActiveSheet.Name = "Harness wire specification"
        ActiveSheet.Tab.ColorIndex = 6
     
    'CAPM
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set F = fs.GetFile(ChemCAPM)
        Set ts = F.OpenAsTextStream(ForReading, TristateUseDefault)
     
     
        'Definir la ligne de debut de la branche "Harness wire specification"
        Deb_Wire_Spec_M = 1
        While ts.readline <> "% Harness wire specification"
            Deb_Wire_Spec_M = Deb_Wire_Spec_M + 1
        Wend
     
     
     
        'Definir la ligne de debut de la branche "Harness wire specification"
        fin_Wire_Spec_M = Deb_Wire_Spec_M
        While ts.readline <> "% Harness main node components"
            fin_Wire_Spec_M = fin_Wire_Spec_M + 1
        Wend
        '*****************************
     
        'Importation de la section "harness wire specification" de CAPM
        With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & ChemCAPM, Destination:=Sheets("Harness wire specification").Range("A3"))
            .TextFileStartRow = Deb_Wire_Spec_M + 1
            .TextFileParseType = xlDelimited
            .TextFileOtherDelimiter = ":"
            .TextFileColumnDataTypes = Array(1, 1)
            .TextFileTrailingMinusNumbers = True
            .Refresh BackgroundQuery:=False
        End With
     
     
        'Mettre en forme la section en gardant les champs utiles
        Rows(fin_Wire_Spec_M - Deb_Wire_Spec_M + 3 & ":50000").ClearContents
        Range("C:C,J:J,N:N,S:T,W:AE").Select
        Range("W1").Activate
        Selection.Delete Shift:=xlToLeft
     
     
     
        Range(Cells(3, 1), Cells(fin_Wire_Spec_M - Deb_Wire_Spec_M + 2, 17)).Select
        Selection.Sort Key1:=Range("A3"), Order1:=xlAscending, Header:=xlNo, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
     
     
     
     
        Sheets("Harness wire specification").Range("A1:Q1").Merge
        Sheets("Harness wire specification").Range("A1").Value = "CAPM"
        Sheets("Harness wire specification").Range("A2").Value = "WireName"
        Sheets("Harness wire specification").Range("B2").Value = "WireOption"
        Sheets("Harness wire specification").Range("C2").Value = "Color"
        Sheets("Harness wire specification").Range("D2").Value = "WireType"
        Sheets("Harness wire specification").Range("E2").Value = "T°"
        Sheets("Harness wire specification").Range("F2").Value = "UserModule"
        Sheets("Harness wire specification").Range("G2").Value = "MulticoreName"
        Sheets("Harness wire specification").Range("H2").Value = "End1NodeName"
        Sheets("Harness wire specification").Range("I2").Value = "End1Cavity"
        Sheets("Harness wire specification").Range("J2").Value = "End1MaterialCode"
        Sheets("Harness wire specification").Range("K2").Value = "End2NodeName"
        Sheets("Harness wire specification").Range("L2").Value = "End2Cavity"
        Sheets("Harness wire specification").Range("M2").Value = "End2MaterialCode"
        Sheets("Harness wire specification").Range("N2").Value = "IncludeOnBOM"
        Sheets("Harness wire specification").Range("O2").Value = "IncludeOnChart"
        Sheets("Harness wire specification").Range("P2").Value = "Neither"
        Sheets("Harness wire specification").Range("Q2").Value = "Lg"
     
    'CAPE
        Set us = CreateObject("Scripting.FileSystemObject")
        Set E = us.GetFile(ChemCAPE)
        Set us = E.OpenAsTextStream(ForReading, TristateUseDefault)
     
     
        'Definir la ligne de debut de la branche "harness wire specification"
        Deb_Wire_Spec_E = 1
        While us.readline <> "% Harness wire specification"
            Deb_Wire_Spec_E = Deb_Wire_Spec_E + 1
        Wend
     
     
     
        'Definir la ligne de debut de la branche "harness wire specification"
        fin_Wire_Spec_E = Deb_Wire_Spec_E
        While us.readline <> "% Harness main node components"
            fin_Wire_Spec_E = fin_Wire_Spec_E + 1
        Wend
     
     
        'Importation de la section "harness wire specification" de CAPE
        With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & ChemCAPE, Destination:=Sheets("Harness wire specification").Range("S3"))
            .TextFileStartRow = Deb_Wire_Spec_E + 1
            .TextFileParseType = xlDelimited
            .TextFileOtherDelimiter = ":"
            .TextFileColumnDataTypes = Array(1, 1)
            .TextFileTrailingMinusNumbers = True
            .Refresh BackgroundQuery:=False
        End With
     
        'Mettre en forme la section en gardant les champs utiles
        Range("S" & fin_Wire_Spec_E - Deb_Wire_Spec_E + 3 & ":AX50000").ClearContents
        Range("T:U,X:X,AB:AB,AF:AF,AK:AL,AO:AT,Aw:EF").Select
        Range("AW1").Activate
        Selection.Delete Shift:=xlToLeft
     
     
        Range(Cells(3, 19), Cells(fin_Wire_Spec_E - Deb_Wire_Spec_E + 2, 36)).Select
        Selection.Sort Key1:=Range("S3"), Order1:=xlAscending, Header:=xlNo, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
     
        Columns("V:V").Select
        Selection.Insert Shift:=xlToRight
        Columns("AI:AI").Select
        Selection.Copy
        Columns("V:V").Select
        ActiveSheet.Paste
        Range("U6").Select
     
     
        Sheets("Harness wire specification").Range("S1:AH1").Merge
        Sheets("Harness wire specification").Range("S1").Value = "CAPE"
        Sheets("Harness wire specification").Range("S2").Value = "WireName"
        Sheets("Harness wire specification").Range("T2").Value = "Color"
        Sheets("Harness wire specification").Range("U2").Value = "Wire type"
        Sheets("Harness wire specification").Range("V2").Value = "T°"
        Sheets("Harness wire specification").Range("W2").Value = "UserModule"
        Sheets("Harness wire specification").Range("X2").Value = "MulticoreName"
        Sheets("Harness wire specification").Range("Y2").Value = "End1NodeName"
        Sheets("Harness wire specification").Range("Z2").Value = "End1Cavity"
        Sheets("Harness wire specification").Range("AA2").Value = "End1MaterialCode"
        Sheets("Harness wire specification").Range("AB2").Value = "End2NodeName"
        Sheets("Harness wire specification").Range("AC2").Value = "End2Cavity"
        Sheets("Harness wire specification").Range("AD2").Value = "End2MaterialCode"
        Sheets("Harness wire specification").Range("AE2").Value = "IncludeOnBOM"
        Sheets("Harness wire specification").Range("AF2").Value = "IncludeOnChart"
        Sheets("Harness wire specification").Range("AG2").Value = "Neither"
        Sheets("Harness wire specification").Range("AH2").Value = "Lg"
        Sheets("Harness wire specification").Range("AJ2").Value = "Diff Longueure "
     
     
     
        'Mettre en forme les intitulees des champs utils
        Sheets("Harness wire specification").Range("A1:AJ2").Font.Bold = True
        Sheets("Harness wire specification").Range("A1:AI2").HorizontalAlignment = xlCenter
        Range("AJ2").Select
        Selection.Font.ColorIndex = 5
        Cells.Select
        Cells.EntireColumn.AutoFit
        Range("A1:Q1").Select
     
    End Sub
     
    Sub Comparaison_Harness_Wire_Specification()
     
    Position4:
            ChemMat = Application.GetOpenFilename("Text Files (*.txt), *.txt", , "Ouverture du fichier des corespondances materiel")
            If ChemMat = False Then
            toto2 = MsgBox("Vous n'avez pas selectionne Le fichier des corespondances materiel.Desirez vous continuer?", 52, "Erreur")
                If (toto2 = vbYes) Then
                 GoTo Position4
                End If
     
            End If
            ' --- Si on souhaite annuler
                If (toto2 = vbNo) Then
                    End
                End If
     
     
     
            Set fs = CreateObject("Scripting.FileSystemObject")
            Set F = fs.GetFile(ChemMat)
            Set ts = F.OpenAsTextStream(ForReading, TristateUseDefault)
     
     
     
            With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & ChemMat, Destination:=Sheets("Harness wire specification").Range("CA1"))
                                .TextFileStartRow = 2
                                .TextFileParseType = xlDelimited
                                .TextFileOtherDelimiter = ":"
                                .TextFileColumnDataTypes = Array(1, 1)
                                .TextFileTrailingMinusNumbers = True
                                .Refresh BackgroundQuery:=False
            End With
     
     
    '    Sheets("Harness wire specification").Range("AK1:AZ1").Merge
    '    Sheets("Harness wire specification").Range("AK1").Value = "Comparaison CAPM-CAPE"
    '    Sheets("Harness wire specification").Range("AK2").Value = "Comp Numero de fil"
    '    Sheets("Harness wire specification").Range("AL2").Value = "Comp Couleur"
    '    Sheets("Harness wire specification").Range("AM2").Value = "Comp Section"
    '    Sheets("Harness wire specification").Range("AN2").Value = "Comp Classe T°"
    '    Sheets("Harness wire specification").Range("AO2").Value = "Comp User Modul"
    '    Sheets("Harness wire specification").Range("AP2").Value = "Comp MulticoreName "
    '    Sheets("Harness wire specification").Range("AQ2").Value = "Comp End1NodeName"
    '    Sheets("Harness wire specification").Range("AR2").Value = "Comp End1Cavity"
    '    Sheets("Harness wire specification").Range("AS2").Value = "Comp End1MaterialCode"
    '    Sheets("Harness wire specification").Range("AT2").Value = "Comp End2NodeName "
    '    Sheets("Harness wire specification").Range("AU2").Value = "Comp End2Cavity "
    '    Sheets("Harness wire specification").Range("AV2").Value = "Comp End2MaterialCode"
    '    Sheets("Harness wire specification").Range("AW2").Value = "Comp BOM "
    '    Sheets("Harness wire specification").Range("AX2").Value = "Comp Chart "
    '    Sheets("Harness wire specification").Range("AY2").Value = " Surlongueur"
    '    Sheets("Harness wire specification").Range("AZ2").Value = "Diff Longueure "
    '
    '
    '    Sheets("Harness wire specification").Range("AK1:AZ2").Font.Bold = True
    '    Sheets("Harness wire specification").Range("AK1:AZ2").HorizontalAlignment = xlCenter
    '    Cells.Select
    '    Cells.EntireColumn.AutoFit
    '    Range("AK1:AZ1").Select
     
        'trie les donnees pour avoir pouvoir comparer les memes lignes
        i = 3
        While Worksheets("Harness wire specification").Cells(i, 1).Text <> Empty Or Worksheets("Harness wire specification").Cells(i, 19).Text <> Empty
            If Worksheets("Harness wire specification").Cells(i, 1).Text = Worksheets("Harness wire specification").Cells(i, 19).Text Then
                                        i = i + 1
            ElseIf Worksheets("Harness wire specification").Cells(i, 1).Text <> Worksheets("Harness wire specification").Cells(i, 19).Text Then
                Worksheets("Harness wire specification").Cells(1, 100) = Worksheets("Harness wire specification").Cells(i, 1)
                Worksheets("Harness wire specification").Cells(2, 100) = Worksheets("Harness wire specification").Cells(i, 19)
                Call tri("Harness wire specification")
     
                    If Worksheets("Harness wire specification").Cells(1, 100).Text = Worksheets("Harness wire specification").Cells(i, 1).Text Then
                        Range("S" & i & ":AI" & i).Select
                        Selection.Insert Shift:=xlDown
                        Range("S" & i & ":AI" & i).Interior.ColorIndex = 45
                        Range("A" & i & ":Q" & i).Interior.ColorIndex = 45
     
     
                    ElseIf Worksheets("Harness wire specification").Cells(1, 100).Text = Worksheets("Harness wire specification").Cells(i, 19).Text Then
                        Range("A" & i & ":Q" & i).Select
                        Selection.Insert Shift:=xlDown
                        Range("S" & i & ":AI" & i).Interior.ColorIndex = 45
                        Range("A" & i & ":Q" & i).Interior.ColorIndex = 45
     
                    End If
                i = i + 1
            End If
        Wend
     
        'remplacer les . par des virgules pour le calcul de la difference de longueure
     
        Range("Q:Q,AH:AH").Select
        Range("AH2").Activate
        Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
        Range("S1:AH1").Select
     
        ' Avoir les memes departs-arrivees des boitiers
        Dim C1, C2, A1, A2, M1, M2, CI, CII, AI, AII, MI, MII As String
        Dim LineM, LineE As Integer
        For LineM = 3 To i
                C1 = Worksheets("Harness wire specification").Cells(LineM, 8)
                A1 = Worksheets("Harness wire specification").Cells(LineM, 9)
                M1 = Worksheets("Harness wire specification").Cells(LineM, 10)
                C2 = Worksheets("Harness wire specification").Cells(LineM, 11)
                A2 = Worksheets("Harness wire specification").Cells(LineM, 12)
                M2 = Worksheets("Harness wire specification").Cells(LineM, 13)
     
                Worksheets("Harness wire specification").Cells(1, 100) = C1
                Worksheets("Harness wire specification").Cells(2, 100) = C2
     
                Call tri("Harness wire specification")
                If C1 <> Worksheets("Harness wire specification").Cells(1, 100) Then
                Worksheets("Harness wire specification").Cells(LineM, 11) = C1
                Worksheets("Harness wire specification").Cells(LineM, 12) = A1
                Worksheets("Harness wire specification").Cells(LineM, 13) = M1
                Worksheets("Harness wire specification").Cells(LineM, 8) = C2
                Worksheets("Harness wire specification").Cells(LineM, 9) = A2
                Worksheets("Harness wire specification").Cells(LineM, 10) = M2
                End If
     
         Next LineM
     
        For LineE = 3 To i
                CI = Worksheets("Harness wire specification").Cells(LineE, 25)
                AI = Worksheets("Harness wire specification").Cells(LineE, 26)
                MI = Worksheets("Harness wire specification").Cells(LineE, 27)
                CII = Worksheets("Harness wire specification").Cells(LineE, 28)
                AII = Worksheets("Harness wire specification").Cells(LineE, 29)
                MII = Worksheets("Harness wire specification").Cells(LineE, 30)
                Worksheets("Harness wire specification").Cells(1, 100) = CI
                Worksheets("Harness wire specification").Cells(2, 100) = CII
     
                Call tri("Harness wire specification")
                If CI <> Worksheets("Harness wire specification").Cells(1, 100) Then
                Worksheets("Harness wire specification").Cells(LineE, 28) = CI
                Worksheets("Harness wire specification").Cells(LineE, 29) = AI
                Worksheets("Harness wire specification").Cells(LineE, 30) = MI
                Worksheets("Harness wire specification").Cells(LineE, 25) = CII
                Worksheets("Harness wire specification").Cells(LineE, 26) = AII
                Worksheets("Harness wire specification").Cells(LineE, 27) = MII
                End If
     
         Next LineE
     
         Worksheets("Harness wire specification").Cells(1, 1).Select
     
        'Comparaison
     
        Ecart_Wire_Spec = 0
        For J = 3 To i - 1
         t = 0
        If Cells(J, 1).Interior.ColorIndex = 45 Then
            Range("A" & J & ":Q" & J).Interior.ColorIndex = 45
        Else
     
            For K = 1 To 17
     
                Select Case K
     
                    Case 2
                    GoTo Liaison2
     
          'Comparaison des couleurs y inclu les couleurs fonctionnelles
                    Case 3
                    If Cells(J, K + 17).Value = "ND" Then
                            If Cells(J, K).Value = "NR" Or Cells(J, K).Value = "VJ" Or Cells(J, K).Value = "OR" Then
                                If Cells(J, K + 17).Value = Cells(J, K).Value Then
     
    '                                Cells(J, K + 35).Value = "OK"
    '                                Cells(J, K + 35).Interior.ColorIndex = 4
                                    Cells(J, K + 17).Interior.ColorIndex = 4
                                    Cells(J, K).Interior.ColorIndex = 4
     
                                Else
     
    '                                Cells(J, K + 35).Value = "NOK"
    '                                Cells(J, K + 35).Interior.ColorIndex = 3
                                    Cells(J, K + 17).Interior.ColorIndex = 3
                                    Cells(J, K).Interior.ColorIndex = 3
                                    t = 1
     
                                End If
                            Else
     
    '                            Cells(J, K + 35).Value = "OK"
    '                            Cells(J, K + 35).Interior.ColorIndex = 4
                                Cells(J, K + 17).Interior.ColorIndex = 4
                                Cells(J, K).Interior.ColorIndex = 4
                            End If
     
                        Else
                            If Cells(J, K).Value = Cells(J, K + 17).Value Then
    '                            Cells(J, K + 35).Value = "OK"
    '                            Cells(J, K + 35).Interior.ColorIndex = 4
                                Cells(J, K + 17).Interior.ColorIndex = 4
                                Cells(J, K).Interior.ColorIndex = 4
                            Else
    '                            Cells(J, K + 35).Value = "NOK"
    '                            Cells(J, K + 35).Interior.ColorIndex = 3
                                Cells(J, K + 17).Interior.ColorIndex = 3
                                Cells(J, K).Interior.ColorIndex = 3
                                t = 1
                            End If
     
                        End If
     
                    Case 4
     
                    If Cells(J, K).Value = Cells(J, K + 17).Value Then
    '                        Cells(J, K + 35).Value = "OK"
    '                        Cells(J, K + 35).Interior.ColorIndex = 4
                            Cells(J, K + 17).Interior.ColorIndex = 4
                            Cells(J, K).Interior.ColorIndex = 4
                        Else
    '                        Cells(J, K + 35).Value = "NOK"
    '                        Cells(J, K + 35).Interior.ColorIndex = 3
                            Cells(J, K + 17).Interior.ColorIndex = 3
                            Cells(J, K).Interior.ColorIndex = 3
                            t = 1
                        End If
     
                    Case 5
     
     
                        Clas_E = Cells(J, K + 17).Value
                        lg = Len(Clas_E)
                        For B = 1 To lg
                           If Mid(Clas_E, B, 1) = "_" Then Exit For
                        Next B
                        Clas_E = Mid(Clas_E, 1, B - 1)
                        M = 1
                        existE = 0
                        While Cells(M, 79) <> "" And existE = 0
                            If Cells(M, 79) = Clas_E Then
                                Clas_M = Cells(M, 80)
                                existE = 1
                            Else
                                M = M + 1
     
                            End If
                        Wend
     
                        If existE = 0 Then
    '                       Cells(J, K + 35).Value = "NOK"
    '                       Cells(J, K + 35).Interior.ColorIndex = 3
                            Cells(J, K + 17).Interior.ColorIndex = 3
                            Cells(J, K).Interior.ColorIndex = 3
                            t = 1
                        Else
                            If Cells(J, K).Value = Clas_M Then
    '                            Cells(J, K + 35).Value = "OK"
    '                            Cells(J, K + 35).Interior.ColorIndex = 4
                                Cells(J, K + 17).Interior.ColorIndex = 4
                                Cells(J, K).Interior.ColorIndex = 4
                            Else
    '                            Cells(J, K + 35).Value = "NOK"
    '                            Cells(J, K + 35).Interior.ColorIndex = 3
                                Cells(J, K + 17).Interior.ColorIndex = 3
                                Cells(J, K).Interior.ColorIndex = 3
                                t = 1
                            End If
                        End If
     
                    Case 6, 8, 9, 11, 12, 14, 15
     
                    If Cells(J, K).Value = Cells(J, K + 17).Value Then
    '                        Cells(J, K + 35).Value = "OK"
    '                        Cells(J, K + 35).Interior.ColorIndex = 4
                            Cells(J, K + 17).Interior.ColorIndex = 4
                            Cells(J, K).Interior.ColorIndex = 4
                        Else
    '                        Cells(J, K + 35).Value = "NOK"
    '                        Cells(J, K + 35).Interior.ColorIndex = 3
                            Cells(J, K + 17).Interior.ColorIndex = 3
                            Cells(J, K).Interior.ColorIndex = 3
                            t = 1
                        End If
     
                   Case 7
                           If Cells(J, K).Value <> "" And Cells(J, K).Value <> "" Then
     
                                If (Cells(J, K).Value <> "" And Cells(J, K).Value = "") Or (Cells(J, K).Value = "" And Cells(J, K).Value <> "") Then
    '                                    Cells(J, K + 35).Value = "NOK"
    '                                    Cells(J, K + 35).Interior.ColorIndex = 3
                                        Cells(J, K + 17).Interior.ColorIndex = 3
                                        Cells(J, K).Interior.ColorIndex = 3
                                        t = 1
                                Else
     
                                        Dim MCCAM As String
                                        If Mid(Cells(J, K).Value, 1, 2) = "CB" Then
                                             MCCAM = Cells(J, K).Value
                                        Else
                                             Dim s As Integer
                                             For s = 1 To Len(Cells(J, K).Value)
                                                 If IsNumeric(Mid(Right(Cells(J, K).Value, s), 1, 1)) Then
                                             Exit For
                                             End If
                                             Next s
     
                                             MCCAM = Mid(Cells(J, K).Value, 1, Len(Cells(J, K).Value) - s) & Right(Cells(J, K).Value, s - 1)
                                        End If
     
                                        If Cells(J, 24).Value = MCCAM Then
    '                                         Cells(J, K + 35).Value = "OK"
    '                                         Cells(J, K + 35).Interior.ColorIndex = 4
                                             Cells(J, K + 17).Interior.ColorIndex = 4
                                             Cells(J, K).Interior.ColorIndex = 4
                                        Else
    '                                        Cells(J, K + 35).Value = "NOK"
    '                                        Cells(J, K + 35).Interior.ColorIndex = 3
                                            Cells(J, K + 17).Interior.ColorIndex = 3
                                            Cells(J, K).Interior.ColorIndex = 3
                                             t = 1
                                        End If
                                End If
                        End If
     
                    Case 10
     
                            If Mid(Cells(J, K - 2).Value, 1, 1) = "E" Or Mid(Cells(J, K - 2).Value, 1, 2) = "NE" Then
    '                            Cells(J, K + 35).Value = "OK"
    '                            Cells(J, K + 35).Interior.ColorIndex = 4
                                Cells(J, K + 17).Interior.ColorIndex = 4
                                Cells(J, K).Interior.ColorIndex = 4
                         Else
                            If Cells(J, K).Value = Cells(J, K + 17).Value Then
    '                           Cells(J, K + 35).Value = "OK"
    '                           Cells(J, K + 35).Interior.ColorIndex = 4
                               Cells(J, K + 17).Interior.ColorIndex = 4
                               Cells(J, K).Interior.ColorIndex = 4
                        Else
    '                           Cells(J, K + 35).Value = "NOK"
    '                           Cells(J, K + 35).Interior.ColorIndex = 3
                               Cells(J, K + 17).Interior.ColorIndex = 3
                               Cells(J, K).Interior.ColorIndex = 3
                            t = 1
                        End If
                            End If
                    Case 13
                            toto = Mid(Cells(J, K - 2).Value, 1, 1)
                            If Mid(Cells(J, K - 2).Value, 1, 1) = "E" Or Mid(Cells(J, K - 2).Value, 1, 2) = "NE" Then
    '                            Cells(J, K + 35).Value = "OK"
    '                            Cells(J, K + 35).Interior.ColorIndex = 4
                                Cells(J, K + 17).Interior.ColorIndex = 4
                                Cells(J, K).Interior.ColorIndex = 4
                            Else
                            If Cells(J, K).Value = Cells(J, K + 17).Value Then
    '                           Cells(J, K + 35).Value = "OK"
    '                           Cells(J, K + 35).Interior.ColorIndex = 4
                               Cells(J, K + 17).Interior.ColorIndex = 4
                               Cells(J, K).Interior.ColorIndex = 4
                        Else
    '                           Cells(J, K + 35).Value = "NOK"
    '                           Cells(J, K + 35).Interior.ColorIndex = 3
                               Cells(J, K + 17).Interior.ColorIndex = 3
                               Cells(J, K).Interior.ColorIndex = 3
                            t = 1
                        End If
                            End If
     
                    Case 16
     
                            If UCase(Cells(J, K).Value) = UCase(Cells(J, K + 17).Value) Then
    '                            Cells(J, K + 35).Value = "OK"
    '                            Cells(J, K + 35).Interior.ColorIndex = 4
                                Cells(J, K + 17).Interior.ColorIndex = 4
                                Cells(J, K).Interior.ColorIndex = 4
                            Else
    '                            Cells(J, K + 35).Value = "NOK"
    '                            Cells(J, K + 35).Interior.ColorIndex = 3
                                Cells(J, K + 17).Interior.ColorIndex = 3
                                Cells(J, K).Interior.ColorIndex = 3
                            End If
     
     
     
     
                    Case 17
     
                        'Cells(J, K + 19).Value = Abs(Cells(J, K).Value - Cells(J, K + 17).Value)
     
                    Case Else
     
    Laison1:
     
                        If Cells(J, K).Value = Cells(J, K + 18).Value Then
    '                        Cells(J, K + 36).Value = "OK"
    '                        Cells(J, K + 36).Interior.ColorIndex = 4
                            Cells(J, K + 18).Interior.ColorIndex = 4
                            Cells(J, K).Interior.ColorIndex = 4
                        Else
    '                        Cells(J, K + 36).Value = "NOK"
    '                        Cells(J, K + 36).Interior.ColorIndex = 3
                            Cells(J, K + 18).Interior.ColorIndex = 3
                            Cells(J, K).Interior.ColorIndex = 3
                            t = 1
                        End If
     
                    End Select
    Liaison2:
            Next K
     
            If t > 0 Then
                Ecart_Wire_Spec = Ecart_Wire_Spec + 1 'Nombre d'elements dont une ou plusieures caracteriqtiques sont differentes
            End If
        End If
        Next J
     
        ActiveWindow.Zoom = 85
        ActiveWindow.SmallScroll up:=2000
     
        NB_Element_comp_Wire_Spec = i - 3 'Nombre d'elements compares
     
        Cells.Select
        With Selection
            .HorizontalAlignment = xlLeft
            .VerticalAlignment = xlBottom
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
        End With
        Range("A1:AJ" & i - 1).Select
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlInsideVertical)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlInsideHorizontal)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlInsideVertical)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlInsideHorizontal)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        Range("A1:Q1,A2:Q2,S1:AJ1,S2:AJ2").Select
      ' Range("AK2").Activate
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlInsideVertical)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        ActiveWindow.ScrollColumn = 28
        ActiveWindow.ScrollColumn = 27
        ActiveWindow.ScrollColumn = 26
        ActiveWindow.ScrollColumn = 22
        ActiveWindow.ScrollColumn = 21
        ActiveWindow.ScrollColumn = 20
        ActiveWindow.ScrollColumn = 17
        ActiveWindow.ScrollColumn = 11
        ActiveWindow.ScrollColumn = 9
        ActiveWindow.ScrollColumn = 1
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlBottom
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
        End With
        ActiveWindow.ScrollColumn = 28
        ActiveWindow.ScrollColumn = 27
        ActiveWindow.ScrollColumn = 20
        ActiveWindow.ScrollColumn = 19
        ActiveWindow.ScrollColumn = 17
        ActiveWindow.ScrollColumn = 15
        ActiveWindow.ScrollColumn = 13
        ActiveWindow.ScrollColumn = 12
        ActiveWindow.ScrollColumn = 10
        ActiveWindow.ScrollColumn = 8
        ActiveWindow.ScrollColumn = 1
        Range("A2:AJ" & i - 1).Select
        Selection.AutoFilter
        ActiveWindow.SmallScroll Down:=-9
        Rows("3:3").Select
        ActiveWindow.FreezePanes = True
        Range("A3").Select
     
        'Afficher les resultats sur la Synthese
        Sheets("Synthese").Cells(15, 2).Value = NB_Element_comp_Wire_Spec
        Sheets("Synthese").Cells(16, 2).Value = Ecart_Wire_Spec
     
     
    End Sub
    Sur le résultat vous trouverez plusieurs colonne qui rassemble les données du fichier text1 comparer par d'autres les données du fichier text2
    La comparaison est indiqué par des colleurs:
    Vert= les données sont pareils.
    Rouge= les données ne sont pas pareils.

    La modif souhaitée:
    Sur le résultat on a une colonne s'appelle "WireOption" qui existe avec les colonnes qui rassembles les données du fichier text1 mais n'existe pas sur les colonnes qui rassemble les données du fichiers text2.

    Merci d'avance pour votre aide

  4. #4
    Inactif
    Homme Profil pro
    Ingénieur développement matériel électronique
    Inscrit en
    Novembre 2011
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Ingénieur développement matériel électronique
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Novembre 2011
    Messages : 4
    Par défaut
    resultat
    Fichiers attachés Fichiers attachés

Discussions similaires

  1. [XL-2003] Macro de comparaison "en live"
    Par Edaine dans le forum Macros et VBA Excel
    Réponses: 0
    Dernier message: 30/05/2011, 08h41
  2. [XL-2007] Macro de comparaison
    Par Raphael39 dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 08/05/2011, 10h45
  3. Macro Excel : Comparaison de 2 feuilles
    Par michaeljeru dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 19/10/2010, 17h21
  4. [XL-2002] Macro de comparaison d'une cellule d'une feuille avec une cellule d'une autre feuille.
    Par steelydan dans le forum Macros et VBA Excel
    Réponses: 6
    Dernier message: 08/09/2010, 12h59
  5. Creer une macro de comparaison ?
    Par gregounnet dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 24/07/2007, 17h42

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