Sub EONIATEST_IV()
'crédits à Docmarti pour l'ouverture du CSV ;o)
Dim Chemin$, fCSV As Workbook, NewTxtFile As Workbook, fic, dl&, ncol, arrFor
Chemin = ThisWorkbook.Path & "\"
fic = Application.GetOpenFilename("Fichiers CSV (*.csv), *.csv")
If fic = False Then
Exit Sub
End If
Application.ScreenUpdating = False 'fige écran
Set fCSV = Workbooks.Open(fic, , , 2, , , True, , , , , , False, local:=True)
Set NewTxtFile = Workbooks.Add(xlWBATWorksheet)
fCSV.Sheets(1).Copy After:=NewTxtFile.Sheets(1): fCSV.Close False
With NewTxtFile
.Sheets(1).Name = "EXPORT_TXT"
With .Sheets(2)
.Name = "eonia"
.Columns("C:G").Delete: .Rows("1:8").Delete
dl = .Cells(Rows.Count, 1).End(xlUp).Row
End With
With .Sheets("EXPORT_TXT")
.Activate
ncol = Array(1, 9, 50, 61, 76)
arrFor = Array("=""IN""", "=""EON""", "=TEXT(eonia!RC[-49],""aaaammjj"")", "=eonia!RC[-59]", "=eonia!RC[-74]")
For i = 0 To 4
.Cells(1, ncol(i)).FormulaR1C1 = arrFor(i)
Next i
.Range("A1:BX1").AutoFill Destination:=Range("A1:BX" & dl), Type:=xlFillDefault
.UsedRange.Value = .UsedRange.Value
End With
Application.DisplayAlerts = False 'inhibe alert message
.Sheets(2).Delete
.SaveAs Chemin & "Export_Test" & Format(Date, "ddmmyyyy") & ".txt", xlText, False
.Close True
Application.DisplayAlerts = True
End With
MsgBox "Traitement terminé mais c'est pas beau à voir ;o) "
Application.ScreenUpdating = True
End Sub