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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
Sub ReadDataFromCloseFile()
On Error GoTo ErrHandler
Application.ScreenUpdating = False
Dim dir As String
Dim file As String
dir = "C:\mon_chemin"
ChDrive "C"
ChDir dir
file = Application.GetOpenFilename()
'if file different of "Faux" (False As String)
If file <> "Faux" Then
Dim src As Workbook
Dim DEST As Workbook
Set DEST = ThisWorkbook
' OPEN THE SOURCE EXCEL WORKBOOK IN "READ ONLY MODE".
Set src = Workbooks.Open(file, True, True)
'GET THE TOTAL ROWS FROM THE SOURCE WORKBOOK.
Dim iTotalRows As Integer
iTotalRows = src.Worksheets("ADX-UAE Alertes").Range("C16:C" & Cells(Rows.Count, "C").End(xlUp).Row).Rows.Count
'Applique un filtre sur la colonne 23
src.Worksheets("ADX-UAE Alertes").Range("$W$16:$W" & iTotalRows).AutoFilter Field:=23, Criteria1:="BHL en cours Action support FAL"
'Copie la selection sur le classeur ouvert
src.Worksheets("ADX-UAE Alertes").Range("A15:V").End(xlDown).SpecialCells(xlCellTypeVisible).Select
Application.CutCopyMode = False
Selection.Copy
'Colle la selection sur le classeur actif
ActiveSheet.Paste Destination:=DEST.Worksheets("Extract J").Range("A2")
' CLEAR CLIPBOARD
Application.CutCopyMode = False
' CLOSE THE SOURCE FILE.
src.Close False ' FALSE - DON'T SAVE THE SOURCE FILE.
Set src = Nothing
End If
MsgBox "copie appliquée !"
ErrHandler:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub |
Partager