Re : copier les cellules d'aun fichier à l'autre
Bonjour, Hippolite,
tout d'abord, merci d'avoir s'intéressé à mon problème! et merci pour tes conseils concernant la définition de besoin! c'est juste manque d’expérience.
En fait, j'ai trouvé une solution. voici le macro:
Sub Copying_A_2_X()
With lancement
cc = 1
Do While Not IsEmpty(.Cells(1, cc))
If UCase(.Cells(1, cc)) = UCase("N° de lancement") Then
cc_Out_N_Lancement = cc
ElseIf UCase(.Cells(1, cc)) = UCase("Modèle") Then
cc_Out_Modele = cc
ElseIf UCase(.Cells(1, cc)) = UCase("Pointure") Then
cc_Out_Pointure = cc
ElseIf UCase(.Cells(1, cc)) = UCase("couleur") Then
cc_Out_Couleur = cc
ElseIf UCase(.Cells(1, cc)) = UCase("Quantité Entrée") Then
cc_Out_QTY = cc
ElseIf UCase(.Cells(1, cc)) = UCase("Date lancement") Then
cc_Out_Date_Fin = cc
End If
cc = cc + 1
Loop
End With
With produit
cc = 1
Do While Not IsEmpty(.Cells(1, cc))
If UCase(.Cells(1, cc)) = UCase("N° de lancement") Then
cc_In_N_Lancement = cc
ElseIf UCase(.Cells(1, cc)) = UCase("Modèle") Then
cc_In_Modele = cc
ElseIf UCase(.Cells(1, cc)) = UCase("Pointure") Then
cc_In_Pointure = cc
ElseIf UCase(.Cells(1, cc)) = UCase("couleur") Then
cc_In_Couleur = cc
ElseIf UCase(.Cells(1, cc)) = UCase("Quantité Entrée") Then
cc_In_QTY = cc
ElseIf UCase(.Cells(1, cc)) = UCase("Date") Then
cc_In_Date_Fin = cc
End If
cc = cc + 1
Loop
End With
produit.Activate
rnEnd_Produit = Cells(1000000, cc_In_N_Lancement).End(xlUp).Row
rc_Produit = rnEnd_Produit + 1
lancement.Activate
rnEnd_Lancement = Cells(1000000, cc_Out_N_Lancement).End(xlUp).Row
For rc_Lancement = 2 To rnEnd_Lancement
If Not IsEmpty(Cells(rc_Lancement, cc_Out_N_Lancement)) Then
produit.Cells(rc_Produit, cc_In_N_Lancement) = Cells(rc_Lancement, cc_Out_N_Lancement)
produit.Cells(rc_Produit, cc_In_Modele) = Cells(rc_Lancement, cc_Out_Modele)
produit.Cells(rc_Produit, cc_In_Pointure) = Cells(rc_Lancement, cc_Out_Pointure)
produit.Cells(rc_Produit, cc_In_Couleur) = Cells(rc_Lancement, cc_Out_Couleur)
produit.Cells(rc_Produit, cc_In_QTY) = Cells(rc_Lancement, cc_Out_QTY)
produit.Cells(rc_Produit, cc_In_Date_Fin) = Cells(rc_Lancement, cc_Out_Date_Fin)
rc_Produit = rc_Produit + 1
Else
Rows(rc_Lancement).Interior.Color = 255
End If
Next rc_Lancement
If Not IsEmpty(Cells(2, cc_Out_N_Lancement)) Then
Range(Rows(2), Rows(rnEnd_Lancement)).ClearContents
End If
produit.Activate
End Sub
A+