'Open les variable file Set w = Workbooks.Open(ThisWorkbook.Sheets("Interface").Range("E4")) w.Worksheets(1).Activate w.ActiveSheet.Cells.Copy Destination:=ThisWorkbook.Sheets("Les variables").Range("A1") w.Close savechanges:=False
'open data file Set w1 = Workbooks.Open(ThisWorkbook.Sheets("Interface").Range("E6")) lr = w1.ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row w1.ActiveSheet.Range("C1", w1.ActiveSheet.Range("C" & lr)).Copy Destination:=ThisWorkbook.Sheets("Feuil1").Range("A1") ThisWorkbook.Activate ThisWorkbook.Sheets("Feuil1").Activate 'call macro Call decoupe ThisWorkbook.Sheets("Feuil1").Columns("A:B").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove w1.ActiveSheet.Range("A1", w1.ActiveSheet.Range("B" & lr)).Copy Destination:=ThisWorkbook.Sheets("Feuil1").Range("A1") w1.ActiveSheet.Range("E1", w1.ActiveSheet.Range("H" & lr)).Copy Destination:=ThisWorkbook.Sheets("Feuil1").Range("F1") w1.Close savechanges:=False ThisWorkbook.Sheets("Feuil1").Columns("D:D").Delete Shift:=xlToLeft ThisWorkbook.Sheets("Feuil1").Columns.AutoFit MsgBox "Task Completed...." Application.ScreenUpdating = True End Sub Sub GetFilePath1()
Set myFile = Application.FileDialog(msoFileDialogOpen) With myFile .Title = "Choose File" .AllowMultiSelect = False If .Show <> -1 Then Exit Sub End If FileSelected = .SelectedItems(1) End With
ActiveSheet.Range("E4") = FileSelected End Sub Sub GetFilePath2()
Set myFile = Application.FileDialog(msoFileDialogOpen) With myFile .Title = "Choose File" .AllowMultiSelect = False If .Show <> -1 Then Exit Sub End If FileSelected = .SelectedItems(1) End With
ActiveSheet.Range("E6") = FileSelected End Sub
Si vous pouvez m'aider à modifier cette macro pour qu'elle peut ajouter une colonne vide au fichier source avant de faire copier coller, la colonne vide ajoutée doit etre entre colonne C et D.