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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
Sub Récup_Cours_Duree()
'Récupérer les données boursières à partir d'une date précise
'Déclaration des variables
Dim ligne As Integer
Dim derniere As Integer
Dim valeur As Integer
Dim i As Integer
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\Guigui\Downloads\Cotations20140709.txt", Destination:=Range( _
"$A$1"))
.Name = "Cotations20140709"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
'-----------------------------Trier par noms de valeurs------------------------------
'Insérer une colonne
Columns(1).EntireColumn.Insert
'Déterminer le numéro de la dernière ligne
derniere = Range("B1").End(xlDown).Row
'Remplacer les références ISIN par les noms des valeurs
ligne = 1
While ligne <= derniere
With Sheets("TEMP")
.Cells(ligne, 1) = WorksheetFunction.VLookup(.Cells(ligne, 2).Value, Sheets("Libellés").Range("A1:C41"), 2, False)
End With
ligne = ligne + 1
Wend
'Supprimer la colonne des références ISIN
Columns(2).Delete
'Trier le tableau obtenu par ordre alphabétique et le mettre propre
Sheets("TEMP").Range("A1").Select
Selection.CurrentRegion.Select
ActiveSheet.QueryTables("Cotations20140709").Delete
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$G$240"), , xlNo).Name = _
"Tableau4"
Range("Tableau4[#All]").Select
ActiveWorkbook.Worksheets("TEMP").ListObjects("Tableau4").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("TEMP").ListObjects("Tableau4").Sort.SortFields.Add _
Key:=Range("Tableau4[[#All],[Colonne1]]"), SortOn:=xlSortOnValues, Order _
:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("TEMP").ListObjects("Tableau4").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns("G:G").Select
Selection.Cut
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Columns("D:G").Select
Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False |
Partager