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 :

Fusionner la table


Sujet :

Macros et VBA Excel

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Décembre 2011
    Messages
    108
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2011
    Messages : 108
    Points : 0
    Points
    0
    Par défaut Fusionner la table
    Bonjour les experts Codes vba

    Je veux supprimer des lignes de tableau avec des cellules de texte fusionnées et calculer des cellules numériques

    Tableau A Avant la mise en œuvre

    Tableau B Après suppression et combinaison

    l'image jointe

    Nom : Tbl.png
Affichages : 160
Taille : 36,5 Ko

    Merci d'avance

  2. #2
    Expert confirmé
    Homme Profil pro
    Electrotechnicien
    Inscrit en
    Juillet 2016
    Messages
    3 240
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Electrotechnicien

    Informations forums :
    Inscription : Juillet 2016
    Messages : 3 240
    Points : 5 655
    Points
    5 655
    Par défaut
    Bonjour,

    Ceci
    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
    Sub Fusionner_la_table()
        Dim DerLig As Long, Lig_TabB As Long
        Dim d As String, Valeur As String, Da As String
        Application.ScreenUpdating = False
        Range("G2:I" & [G2].End(xlDown).Row).ClearContents
        DerLig = Range("C" & Rows.Count).End(xlUp).Row
        Lig_TabB = 2
        Da = 0
        d = ""
        Valeur = ""
        For i = 2 To DerLig + 1
            If Cells(i, "C") = "" Then
                    Cells(Lig_TabB, "G") = Da
                    Cells(Lig_TabB, "H") = d
                    Cells(Lig_TabB, "I") = Valeur
                    Da = 0
                    d = ""
                    Valeur = ""
                    Lig_TabB = Lig_TabB + 1
            ElseIf Lig_TabB <> 2 Then
                If Cells(i, "D") <> Cells(i + 1, "D") And Cells(i + 1, "D") <> "" Then
                    If IsNumeric(Cells(i, "C")) Then Da = CInt(Da) + Cells(i, "C") Else Da = Da & " " & Cells(i, "C")
                    If Left(Da, 2) = "0 " Then Da = Right(Da, Len(Da) - 2)
                    Cells(Lig_TabB, "G") = Da
                    Cells(Lig_TabB, "H") = d
                    Cells(Lig_TabB, "I") = Valeur
                    Da = 0
                    d = ""
                    Valeur = ""
                    Lig_TabB = Lig_TabB + 1
                Else
                    If IsNumeric(Cells(i, "C")) Then Da = Da + Cells(i, "C") Else Da = Da & " " & Cells(i, "C")
                    If Cells(i, "D") <> "" Then
                        d = Cells(i, "D")
                        Valeur = Cells(i, "E")
                    End If
                End If
            ElseIf Lig_TabB = 2 Then
                If i <> 2 And Cells(i, "D") <> Cells(i + 1, "D") Then
                    If Left(Da, 2) = "0 " Then Da = Right(Da, Len(Da) - 2)
                    Cells(Lig_TabB, "G") = Da
                    Cells(Lig_TabB, "H") = d
                    Cells(Lig_TabB, "I") = Valeur
                    Da = 0
                    d = ""
                    Valeur = ""
                    Lig_TabB = Lig_TabB + 1
                Else
                    If IsNumeric(Cells(i, "C")) Then Da = Da + Cells(i, "C") Else Da = Da & " " & Cells(i, "C")
                    If Cells(i, "D") <> "" Then
                        d = Cells(i, "D")
                        Valeur = Cells(i, "E")
                    End If
                End If
            End If
        Next i
    End Sub
    Le fichier
    Pièce jointe 511138

    Cdlt

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Décembre 2011
    Messages
    108
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2011
    Messages : 108
    Points : 0
    Points
    0
    Par défaut
    Merci Professeur ARTURO83

  4. #4
    Nouveau Candidat au Club
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Décembre 2011
    Messages
    108
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2011
    Messages : 108
    Points : 0
    Points
    0
    Par défaut
    Professeur ARTURO83
    La première table d'instructions n'a pas été fusionnée

    Pièce jointe 511391
    Images attachées Images attachées  

  5. #5
    Expert confirmé
    Homme Profil pro
    Electrotechnicien
    Inscrit en
    Juillet 2016
    Messages
    3 240
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Electrotechnicien

    Informations forums :
    Inscription : Juillet 2016
    Messages : 3 240
    Points : 5 655
    Points
    5 655
    Par défaut
    Bonjour,

    Petit oubli réparé
    le fichier
    Pièce jointe 511397

    le 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
    Sub Fusionner_la_table()
        Dim DerLig As Long, Lig_TabB As Long
        Dim d As String, Valeur As String, Da As String
        Application.ScreenUpdating = False
        Range("G2:I" & [G2].End(xlDown).Row).ClearContents
        DerLig = Range("C" & Rows.Count).End(xlUp).Row
        Lig_TabB = 2
        Da = 0
        d = ""
        Valeur = ""
        For i = 2 To DerLig + 1
            If Cells(i, "C") = "" Then
                    If Left(Da, 2) = "0 " Then Da = Right(Da, Len(Da) - 2)
                    Cells(Lig_TabB, "G") = Da
                    Cells(Lig_TabB, "H") = d
                    Cells(Lig_TabB, "I") = Valeur
                    Da = 0
                    d = ""
                    Valeur = ""
                    Lig_TabB = Lig_TabB + 1
            ElseIf Lig_TabB <> 2 Then
                If Cells(i, "D") <> Cells(i + 1, "D") And Cells(i + 1, "D") <> "" Then
                    If IsNumeric(Cells(i, "C")) Then Da = CInt(Da) + Cells(i, "C") Else Da = Da & " " & Cells(i, "C")
                    If Left(Da, 2) = "0 " Then Da = Right(Da, Len(Da) - 2)
                    Cells(Lig_TabB, "G") = Da
                    Cells(Lig_TabB, "H") = d
                    Cells(Lig_TabB, "I") = Valeur
                    Da = 0
                    d = ""
                    Valeur = ""
                    Lig_TabB = Lig_TabB + 1
                Else
                    If IsNumeric(Cells(i, "C")) Then Da = Da + Cells(i, "C") Else Da = Da & " " & Cells(i, "C")
                    If Cells(i, "D") <> "" Then
                        d = Cells(i, "D")
                        Valeur = Cells(i, "E")
                    End If
                End If
            ElseIf Lig_TabB = 2 Then
                If i <> 2 And Cells(i, "D") <> Cells(i + 1, "D") Then
                    If IsNumeric(Cells(i, "C")) Then Da = Da + Cells(i, "C") Else Da = Da & " " & Cells(i, "C")
                    If Left(Da, 2) = "0 " Then Da = Right(Da, Len(Da) - 2)
                    Cells(Lig_TabB, "G") = Da
                    Cells(Lig_TabB, "H") = d
                    Cells(Lig_TabB, "I") = Valeur
                    Da = 0
                    d = ""
                    Valeur = ""
                    Lig_TabB = Lig_TabB + 1
                Else
                    If IsNumeric(Cells(i, "C")) Then Da = Da + Cells(i, "C") Else Da = Da & " " & Cells(i, "C")
                    If Cells(i, "D") <> "" Then
                        d = Cells(i, "D")
                        Valeur = Cells(i, "E")
                    End If
                End If
            End If
        Next i
    End Sub
    Cdlt

Discussions similaires

  1. fusionner 2 tables
    Par sawati dans le forum SQL Procédural
    Réponses: 2
    Dernier message: 02/07/2006, 15h55
  2. fusionner 2 tables de structure différente
    Par Rcanada dans le forum Access
    Réponses: 9
    Dernier message: 21/04/2006, 09h54
  3. Fusionner deux tables
    Par rdjema dans le forum Langage SQL
    Réponses: 5
    Dernier message: 30/11/2005, 18h42
  4. Fusionner 2 tables Access
    Par zangel dans le forum Access
    Réponses: 7
    Dernier message: 02/11/2005, 08h33
  5. fusionner 2 tables dont les champs sont identiques mais.....
    Par NoobX dans le forum SQL Procédural
    Réponses: 1
    Dernier message: 27/10/2005, 16h12

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