Bonjour à tous,
J'ai fait une macro qui me copie colle les lignes d'un onglet GestionCI dans un autre onglet Gestion des stock sorties.
Voici la macro ci dessous:
Sub CopieLigneSortie() 'copie d'une ligne complete sous condition case R
Dim lig As Integer
Dim lig2 As Integer
With Sheets("GestionCommande")
For lig = .Range("Q42").End(xlUp).Row To 17 Step -1
lig2 = Sheets("GestionStockSorties").Range("A65536").End(xlUp).Row
If .Range("Q" & lig).Value = "Ok " Then
.Range("B" & lig).Copy Sheets("GestionStockSorties").Range("A" & lig2 + 1)
.Range("D" & lig).Copy
With Sheets("GestionStockSorties").Range("B" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("M" & lig).Copy
With Sheets("GestionStockSorties").Range("C" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("O" & lig).Copy
With Sheets("GestionStockSorties").Range("D" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("P" & lig).Copy
With Sheets("GestionStockSorties").Range("E" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
End If
Next
End With
End Sub
Elle fonctionne très bien.
Lorsque je la copie colle dans mon fichier de travail, cette macro ne copie plus que la premiere ligne et je dois avouer que je ne comprends pas du tout.
Pourriez vous me dire ce qui vous semble incoherent s'il vous plait?
Voici la macro de l'autre fichier:
Sub CopieLigneSortie() 'copie d'une ligne complete sous condition case Q
Dim lig As Integer
Dim lig2 As Integer
With Sheets("GestionCommande")
For lig = .Range("Q42").End(xlUp).Row To 17 Step -1
lig2 = Sheets("GestionStockSorties").Range("A65536").End(xlUp).Row
If .Range("Q" & lig).Value = "Ok " Then
.Range("B" & lig).Copy Sheets("GestionStockSorties").Range("A" & lig2 + 1)
.Range("D" & lig).Copy
With Sheets("GestionStockSorties").Range("B" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("M" & lig).Copy
With Sheets("GestionStockSorties").Range("C" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("N" & lig).Copy
With Sheets("GestionStockSorties").Range("D" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("P" & lig).Copy
With Sheets("GestionStockSorties").Range("E" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
End If
Sheets("GestionStockSorties").Select
Range("A" & lig2 + 1).Select
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = -1
End With
Next
End With
End Sub
J'ai fait une macro qui me copie colle les lignes d'un onglet GestionCI dans un autre onglet Gestion des stock sorties.
Voici la macro ci dessous:
Sub CopieLigneSortie() 'copie d'une ligne complete sous condition case R
Dim lig As Integer
Dim lig2 As Integer
With Sheets("GestionCommande")
For lig = .Range("Q42").End(xlUp).Row To 17 Step -1
lig2 = Sheets("GestionStockSorties").Range("A65536").End(xlUp).Row
If .Range("Q" & lig).Value = "Ok " Then
.Range("B" & lig).Copy Sheets("GestionStockSorties").Range("A" & lig2 + 1)
.Range("D" & lig).Copy
With Sheets("GestionStockSorties").Range("B" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("M" & lig).Copy
With Sheets("GestionStockSorties").Range("C" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("O" & lig).Copy
With Sheets("GestionStockSorties").Range("D" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("P" & lig).Copy
With Sheets("GestionStockSorties").Range("E" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
End If
Next
End With
End Sub
Elle fonctionne très bien.
Lorsque je la copie colle dans mon fichier de travail, cette macro ne copie plus que la premiere ligne et je dois avouer que je ne comprends pas du tout.
Pourriez vous me dire ce qui vous semble incoherent s'il vous plait?
Voici la macro de l'autre fichier:
Sub CopieLigneSortie() 'copie d'une ligne complete sous condition case Q
Dim lig As Integer
Dim lig2 As Integer
With Sheets("GestionCommande")
For lig = .Range("Q42").End(xlUp).Row To 17 Step -1
lig2 = Sheets("GestionStockSorties").Range("A65536").End(xlUp).Row
If .Range("Q" & lig).Value = "Ok " Then
.Range("B" & lig).Copy Sheets("GestionStockSorties").Range("A" & lig2 + 1)
.Range("D" & lig).Copy
With Sheets("GestionStockSorties").Range("B" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("M" & lig).Copy
With Sheets("GestionStockSorties").Range("C" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("N" & lig).Copy
With Sheets("GestionStockSorties").Range("D" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
.Range("P" & lig).Copy
With Sheets("GestionStockSorties").Range("E" & lig2 + 1)
.PasteSpecial xlPasteValues
End With
End If
Sheets("GestionStockSorties").Select
Range("A" & lig2 + 1).Select
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = -1
End With
Next
End With
End Sub