échange de données entre deux fichiers excel
Salut à tous,
j'ai un fichier excel qu'on appellera maitre et un autre esclave.
Dans esclave, j'ai un tableau.
Lorsque je clique sur un bouton sur le fichier maitre, j'aimerai lancer une macro qui va chercher certaines valeurs du tableau du fichier esclave.
N'étant qu'un débutant en VBA je n'ai malheureusement que ce bout de code à vous présenter :
Code:
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
|
Sub Miseajour()
Dim maitre
Set maitre = Workbooks(1).Sheets(2)
InL = maitre.Cells.SpecialCells(xlCellTypeLastCell).Row
InC = maitre.Cells.SpecialCells(xlCellTypeLastCell).Column
Dim ExcelApp As Excel.Application
Set ExcelApp = New Excel.Application
With ExcelApp
.Workbooks.Open Filename:="lechemindacces\Nouveau dossier\esclave.xls"
InLex = .Sheets(2).Cells.SpecialCells(xlCellTypeLastCell).Row
InCex = .Sheets(2).Cells.SpecialCells(xlCellTypeLastCell).Column
For L = 2 To InLex
If (.Sheets(2).Cells(L, 1).Interior.ColorIndex = 3) Then
maitre.Range(Cells(InL, 1), Cells(InL, InCex)) = .Sheets(2).Range(Cells(L, 1), Cells(L, InCex))
End If
Next
End With
ExcelApp.Quit
Set ExcelApp = Nothing
End Sub |
Merci à tous pour votre aide