Workbooks("test macro milages.xls")
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionSet ws1 = excel.Workbooks("test macro milages.xls").Sheets("Page1-1")
Private Sub cmdTranfertDe_Click() Dim ws1 As Excel.Worksheet Dim ws2 As Excel.Worksheet Dim Range1 As Excel.Range Dim Range2 As Excel.Range Dim Cell1 As Excel.Range Set ws1 = Excel.Workbooks("test macro milages.xls").Sheets("Page1-1") Set ws2 = Excel.Workbooks("Classeur.xlsx").Sheets("Feuil1") Set Range1 = Excel.Intersect(ws1.Columns("E:E"), ws1.UsedRange) Set Range2 = Excel.Intersect(ws2.Columns("A:B"), ws2.UsedRange) On Error Resume Next '-- a good use of this in cases VLookup fails For Each Cell1 In Range1.Cells Cell1.Offset(0, 16).Value = Excel.Application.WorksheetFunction.VLookup(Cell1, Range2, 2, 0) '-- if VLookup fails, Cell1.Offset(0, 16) in column "U" is unchanged '-- if required the next line below can be used: 'If Err Then Cell1.Offset(0, 16).Value = "": Err.Clear Next On Error GoTo 0 End Sub