Sub choisir_fichierII()
Dim Mon_FiltreA
Dim WBK As Workbook, TXTFile As Workbook, FichierChoisi ' déclarations
Dim pf As Range
Set WBK = ThisWorkbook
Mon_FiltreA = Array("FILE", "ANGLES", "CNTCT#", "STDDEV", "DISTS ", "GAPS", "A", "B")
FichierChoisi = Application.GetOpenFilename("Fichiers Txt,*.txt")
Application.ScreenUpdating = False
If Not FichierChoisi = False Then
Workbooks.OpenText Filename:=FichierChoisi, DataType:=xlDelimited, Tab:=True
Set TXTFile = ActiveWorkbook
ActiveWorkbook.Sheets(1).Copy WBK.Sheets(1) ' on copie tout dans le classeur stockant la macro
TXTFile.Close False ' on ferme mesure.txt
End If
With WBK.Sheets(1)
'--- 1ere ligne en gras
.Range("A1", [A1].End(xlToRight)).Font.Bold = True
.Name = "mesure"
End With
WBK.Sheets("mesure").Move , WBK.Worksheets(WBK.Worksheets.Count)
'suppression des lignes en trop
With WBK.Sheets("mesure")
.Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
.Range("N1:N8") = Application.Transpose(Mon_FiltreA)
.Range("A1:A" & .[A65536].End(xlUp).Row).AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("N1:N8"), Unique:=False
Set pf = .Range("_FilterDataBase")
pf.Offset(1, 0).Resize(pf.Rows.Count - 1).SpecialCells(12).EntireRow.Delete
.ShowAllData
.Columns(14).Delete
End With
End Sub