Bonjour a tous,
J'essaie de copier une plage de données d'un classeur excel X a un classeur excel Y. La plage de donnes du classeur X est toujours la même, cependant, dans le classeur Y, les cellules ou je vais coller la plage de donnes change.
Je suis en train d utilser le code ci dessous,
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
| Sub AJOUT()
Dim Plage_Cible As Range
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim xlApp1 As Excel.Application
Dim xlBook1 As Excel.Workbook
Dim xlsheet1 As Excel.Worksheet
Set xlApp = New Excel.Application
xlApp.Visible = False
Set xlApp1 = New Excel.Application
xlApp1.Visible = False
mypath = "C:\Users\MC\Downloads\TDB.xlsm"
If Not Dir(mypath, vbNormal) = "" Then
Set xlBook = xlApp.Workbooks.Open(mypath)
NomFichierSortie = "C:\Users\MC\Downloads\TDBpre.xlsm"
If Not Dir(NomFichierSortie, vbNormal) = "" Then
Set xlBook1 = xlApp1.Workbooks.Open(NomFichierSortie)
xlBook.Worksheets("Data_Tend").Range("A2:k8").SpecialCells(xlCellTypeFormulas, xlNumbers + xlTextValues).Copy xlBook1.Worksheets("Data_Tend").Range("A2:k8")
xlBook1.Close
End If
' On ferme le second
xlBook.Close
End If
'xlBook.Save
'xlBook.Close
xlApp.Quit
Set xlsheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End Sub |
mais j en ai un problem au niveu de cet partie -->
xlBook.Worksheets("Data_Tend").Range("A2:k8").SpecialCells(xlCellTypeFormulas, xlNumbers + xlTextValues).Copy xlBook1.Worksheets("Data_Tend").Range("A2:k8")
qui m'affiche l'error 424 Object required, je ne sais pas ou se trouve l erreur.
Merci de votre aide!.
Mc.
Partager