1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| Sub Copie_s52()
Dim dls1&, dls52&, dcol&
Dim pls1%, pls2%
Dim vlg9$, chemin$, fich1$, fich52$
'1re ligne de données du fichier 1
pls1 = 9
'1re ligne de données du fichier 52 (on peut ne mettre qu'une variable, c'est pour le cas _
'ce serait différent
pls52 = 9
'dernière colonne uitlisée
dcol = 9
'modifier pour le vrai chemin
chemin = "C:\A_Documents\"
'modifier avec le véritable nom
fich1 = "PHP_Semaine_1A.xls"
'modifier avec le véritable nom
fich52 = "PHP_Semaine_52.xls"
On Error Resume Next
Workbooks(fich52).Activate
If Err <> 0 Then
If Dir(chemin & fich52) = "" Then
MsgBox "Le fichier n'a pas été trouvé.Vérifiez !"
End
End If
Workbooks.Open Filename:=chemin & fich52
End If
vlg9 = Workbooks(fich52).Sheets("Feuil1").Range(Cells(pls52, 1), Cells(pls52, 1))
If vlg9 = "" Then
MsgBox "Aucune donnée à copier n'a été trouvée en ligne 9 colonne A."
End
Else
dls52 = Workbooks(fich52).Sheets("Feuil1").Range("A" & Rows.Count).End(xlUp).Row
dls1 = Workbooks(fich1).Sheets("Feuil1").Range("A" & Rows.Count).End(xlUp).Row + 1
End If
Workbooks(fich52).Sheets("Feuil1").Activate
Range(Cells(pls52, 1), Cells(dls52, dcol)).Select
Application.CutCopyMode = False
Selection.Copy
Workbooks(fich1).Sheets("Feuil1").Activate
Range(Cells(dls1, 1), Cells(dls1, 1)).Select
ActiveSheet.Paste
End Sub |
Partager