Bonjour,
Attention les expressions Range ou Cells non rattachées explicitement à un objet sont implicitement rattachées à ActiveSheet. Tu as donc écrit en fait
Sheets("Feuil2").Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(1, 10)).Copy Sheets("Feuil3").Range(ActiveSheet.Cells(2, 1), ActiveSheet.Cells(2, 10))
Comme ActiveSheet ne peut être égal à la fois à Feuil2 ET à Feuil3, ça ne va pas le faire.
En fait tu voulais probablement écrire :
Sheets("Feuil2").Range(Sheets("Feuil2").Cells(1, 1), Sheets("Feuil2").Cells(1, 10)).Copy Sheets("Feuil3").Range(Sheets("Feuil2").Cells(2, 1), Sheets("Feuil2").Cells(2, 10))
En passant Sheets a le même biais et est relative à Activeworkbook ; donc pour éviter tout problème ultérieur, et comme ça commence à être verbeux, je suggère :
1 2 3 4 5 6
| With ThisWorkBook.Sheets("Feuil2")
.Range(.Cells(1, 1), .Cells(1, 10)).Copy
End With
With Sheets("Feuil3")
.Range(.Cells(2, 1), .Cells(2, 10)).PasteSpecial xlPasteAll
End With |
Partager