bonjour à tous, j'ai fais un code répétitif pour chaque cas, est'il possible de simplifier pour faire un code qui prends en compte toutes les valeurs de D2 de 0 à 1000 sans recopier et changer manuellement ? merci d'avance :
Sheets("Feuil1").Select
If Range("D2") = 2 Then
Rows("8:8").Select
Selection.Delete
Sheets("extraction").Select
Columns("J:J").Select
Selection.Cut
Columns("G:G").Select
ActiveSheet.Paste
Columns("J:J").Select
Selection.Delete Shift:=xlToLeft
Sheets("Feuil1").Select
Range("D2") = 1
Exit Sub
End If
If Range("D2") = 3 Then
Rows("9:9").Select
Selection.Delete
Sheets("extraction").Select
Columns("K:K").Select
Selection.Cut
Columns("G:G").Select
ActiveSheet.Paste
Columns("K:K").Select
Selection.Delete Shift:=xlToLeft
Sheets("Feuil1").Select
Range("D2") = 1
Exit Sub
End If
If Range("D2") = 4 Then
Rows("10:10").Select
Selection.Delete
Sheets("extraction").Select
Columns("L:L").Select
Selection.Cut
Columns("G:G").Select
ActiveSheet.Paste
Columns("L:L").Select
Selection.Delete Shift:=xlToLeft
Sheets("Feuil1").Select
Range("D2") = 1
Exit Sub
End If
'.....(etc) de D2 = 2 à D2 = 1000
en sachant que :
colonne G invariable
D2 = 2 alors colonne J et ligne 10
D2 = 3 alors colonne K et ligne 11
... jusqu'à 1000
Sheets("Feuil1").Select
If Range("D2") = 2 Then
Rows("8:8").Select
Selection.Delete
Sheets("extraction").Select
Columns("J:J").Select
Selection.Cut
Columns("G:G").Select
ActiveSheet.Paste
Columns("J:J").Select
Selection.Delete Shift:=xlToLeft
Sheets("Feuil1").Select
Range("D2") = 1
Exit Sub
End If
If Range("D2") = 3 Then
Rows("9:9").Select
Selection.Delete
Sheets("extraction").Select
Columns("K:K").Select
Selection.Cut
Columns("G:G").Select
ActiveSheet.Paste
Columns("K:K").Select
Selection.Delete Shift:=xlToLeft
Sheets("Feuil1").Select
Range("D2") = 1
Exit Sub
End If
If Range("D2") = 4 Then
Rows("10:10").Select
Selection.Delete
Sheets("extraction").Select
Columns("L:L").Select
Selection.Cut
Columns("G:G").Select
ActiveSheet.Paste
Columns("L:L").Select
Selection.Delete Shift:=xlToLeft
Sheets("Feuil1").Select
Range("D2") = 1
Exit Sub
End If
'.....(etc) de D2 = 2 à D2 = 1000
en sachant que :
colonne G invariable
D2 = 2 alors colonne J et ligne 10
D2 = 3 alors colonne K et ligne 11
... jusqu'à 1000