Problème MACRO suppresion ligne sur 2 champs

PhilippeC13

XLDnaute Nouveau
Bonjour,

Dans mon fichier j'ai des lignes en colonne "A" qui commence par RTC et d'autres par EXP.
Par une macro, J'aimerai supprimer toutes les lignes commençant par EXP ayant le même numéro de client et le même numéro de série que la ligne RTC.

Merci de votre aide

Philippe
 

Pièces jointes

  • correction macro.xlsm
    9.5 KB · Affichages: 53

tototiti2008

XLDnaute Barbatruc
Re : Problème MACRO suppresion ligne sur 2 champs

Bonjour Philippe,

un essai

Code:
Sub test()
Dim i As Long, j As Long, Client As String
    Application.ScreenUpdating = False
    For i = 2 To Range("A65536").End(xlUp).Row
        If Range("A" & i).Value = "RTC" Then
            Client = Range("B" & i).Value
            For j = Range("A65536").End(xlUp).Row To 2 Step -1
                If Range("A" & j).Value = "EXP" And Range("B" & j).Value = Client Then
                    Range("A" & j).EntireRow.Delete
                End If
            Next j
        End If
    Next i
    Application.ScreenUpdating = True
End Sub
 

PhilippeC13

XLDnaute Nouveau
Re : Problème MACRO suppresion ligne sur 2 champs

Merci beaucoup pour ta réponse, mas si j'exécute ta macro, il me surprime toutes les lignes avec mon numéro de client j'aimerai une variable supplémentaire, le numéro de série.
Et je suis désolé mais mes connaissance en excel sont limités,

Merci.
 

tototiti2008

XLDnaute Barbatruc
Re : Problème MACRO suppresion ligne sur 2 champs

Re,

Oups, j'avais mal lu...

VB:
Sub test()
Dim i As Long, j As Long, Client As String, NumSerie as String
    Application.ScreenUpdating = False
    For i = 2 To Range("A65536").End(xlUp).Row
        If Range("A" & i).Value = "RTC" Then
            Client = Range("B" & i).Value
            NumSerie = Range("D" & i).Value
            For j = Range("A65536").End(xlUp).Row To 2 Step -1
                If Range("A" & j).Value = "EXP" And Range("B" & j).Value = Client And Range("D" & j).value = NumSerie Then
                    Range("A" & j).EntireRow.Delete
                End If
            Next j
        End If
    Next i
    Application.ScreenUpdating = True
End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 836
Messages
2 092 652
Membres
105 479
dernier inscrit
chaussadas.renaud