MAcro Copier-coller qui ne me prends plus que la première ligne!! Snif!

solo84

XLDnaute Junior
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
 

Pièces jointes

  • GestionCIVersionMAcroOK.xlsm
    37.3 KB · Affichages: 36

solo84

XLDnaute Junior
Re : MAcro Copier-coller qui ne me prends plus que la première ligne!! Snif!

J'ai debloqué une des deux macro en refaisant la mise en page!
Cela fonctionne pour une des macro mais je ne sais pas pourquoi!
Quelqu'un aurait-il une idée s'il vous plait?
 

Discussions similaires

Statistiques des forums

Discussions
312 305
Messages
2 087 084
Membres
103 459
dernier inscrit
Arnocal