Passage a une autre ligne
Bonjour tout le monde,
Je suis débutante en vba , et j'ai besoin de votre aide s'il vous plait
J'ai cette macro qui permet de grouper les différents données pour deux mémés cellules qui se répètent sur plusieurs lignes.
Mon problème c'est que il regroupe les données seulement pour 2 lignes mais pas plus , je voudrai qui'il regroupe les données sur une mémé ligne qui ont les mémés cellule B et C qui se répètent sur plusieurs lignes .
J'arrive pas a trouver le pb dans mon code qui execute seulement pour 2 lignes .
Merci d'avance.
'code VBA
Function inserer(FL2 As Worksheet, lig As Integer, col As Integer)
If (FL2.Cells(lig, 20) <> "") Then
FL2.Cells(col, 19) = FL2.Cells(lig, 19)
FL2.Cells(col, 20) = FL2.Cells(lig, 20)
FL2.Cells(col, 21) = FL2.Cells(lig, 21)
FL2.Cells(col, 22) = FL2.Cells(lig, 22)
ElseIf (FL2.Cells(lig, 26) <> "") Then
FL2.Cells(col, 25) = FL2.Cells(lig, 25)
FL2.Cells(col, 26) = FL2.Cells(lig, 26)
FL2.Cells(col, 27) = FL2.Cells(lig, 27)
ElseIf (FL2.Cells(lig, 31) <> "") Then
FL2.Cells(col, 30) = FL2.Cells(lig, 30)
FL2.Cells(col, 31) = FL2.Cells(lig, 31)
FL2.Cells(col, 32) = FL2.Cells(lig, 32)
ElseIf (FL2.Cells(lig, 37) <> "") Then
FL2.Cells(col, 36) = FL2.Cells(lig, 36)
FL2.Cells(col, 37) = FL2.Cells(lig, 37)
FL2.Cells(col, 38) = FL2.Cells(lig, 38)
ElseIf (FL2.Cells(lig, 42) <> "") Then
FL2.Cells(col, 41) = FL2.Cells(lig, 41)
FL2.Cells(col, 42) = FL2.Cells(lig, 42)
FL2.Cells(col, 43) = FL2.Cells(lig, 43)
End If
End Function
Sub grouper()
Dim FL2 As Worksheet, i As Integer, j As Integer, h As String, lig As Integer, col As Integer
Set FL2 = Worksheets(4)
For i = 10 To 50
For j = 9 To i - 1
If ((FL2.Cells(i, 2) Like FL2.Cells(j, 2)) And (FL2.Cells(i, 3) Like FL2.Cells(j, 3)) And (FL2.Cells(i, 4) Like FL2.Cells(j, 4)) And (FL2.Cells(i, 5) Like FL2.Cells(j, 5))) Then
col = j
lig = i
h = inserer(FL2, lig, col)
Rows(i).Delete
End If
Next j
Next i
End Sub