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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
Dim xlApp As Excel.Application
Dim xlWb As Excel.Workbook
Dim xlSh As Excel.Worksheet
Set xlApp = New Excel.Application
xlApp.Visible = False
'on ouvre le fichier + on se positionne sur la premiere feuille
Set xlWb = xlApp.Workbooks.Open("O:\Portfolio Management\Contrôle et suivi d'activité\Suivi Target Market\20170122-TM-LU.csv", True)
Set xlSh = xlWb.Worksheets(1)
'*************************************************************************************************
' On manipule l'extraction pour conserver uniquement les données nécéssaire
'*************************************************************************************************
'Rows("1:3").Select
'Selection.Delete Shift:=xlUp 'On supprime les 3 premieres lignes
xlSh.Range("A:F").Delete 'On supprime tour à tour les colonnes inutiles
xlSh.Range("B:AE").Delete
xlSh.Range("C:F").Delete
'************************************************************************************************
' On supprime les ISIN vide
'*************************************************************************************************
Range("A1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$B$23221").AutoFilter Field:=1, Criteria1:="="
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
ActiveSheet.Range("$A$1:$B$20108").AutoFilter Field:=1
Cells.Select
Selection.AutoFilter
Range("A3").Select
'*************************************************************************************************
' On supprime les doublons
'*************************************************************************************************
Columns("A:B").Select
ActiveSheet.Range("$A$1:$B$20108").RemoveDuplicates Columns:=Array(1, 2), _
Header:=xlYes
'*************************************************************************************************
' On conserve uniquement les numeriques dans le Profil
'*************************************************************************************************
TitleCellsB = Cells(1, 2)
j = Cells(Rows.Count, 1).End(xlUp).Row
Columns("B:B").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B2:B" & j).FormulaR1C1 = "=left(RC[1],3)"
Range("B2:B" & j).Value = Range("B2:B" & j).Value
Columns("C:C").Delete Shift:=xlToLeft
Cells(1, 2) = TitleCellsB
'*************************************************************************************************
' On concatene les donnees
'*************************************************************************************************
Columns("A:B").Select
ActiveWorkbook.Worksheets("20170122-TM-LU").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("20170122-TM-LU").Sort.SortFields.Add Key:=Range( _
"A2:A10000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("20170122-TM-LU").Sort.SortFields.Add Key:=Range( _
"B2:B10000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("20170122-TM-LU").Sort
.SetRange Range("A1:B10000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
i = 2
Do While Cells(i, 1) <> ""
If Cells(i, 1) = Cells(i + 1, 1) Then
Cells(i, 2) = Cells(i, 2) & ", " & Cells(i + 1, 2)
Rows(i + 1 & ":" & i + 1).Select
Selection.Delete Shift:=xlUp
Else
i = i + 1
End If
Loop
'*************************************************************************************************
' On sauvegarde les données sur l'Excel Liste Valeurs Profils Gestion LU
'*************************************************************************************************
xlApp.DisplayAlerts = False 'Desactiver les alertes
ActiveWorkbook.SaveAs FileName:= _
"O:\Portfolio Management\Contrôle et suivi d'activité\Suivi Target Market\Liste Valeurs Profils Gestion LU.xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
xlApp.DisplayAlerts = True 'Desactiver les alertes
'*************************************************************************************************
' On ferme l'Excel sans sauvegarder
'*************************************************************************************************
xlWb.Close False 'On clôture Extract base clients en sauvegardant
Set xlWb = Nothing 'On libere xlWB
xlApp.Quit 'On ferme l'application Excel
Set xlApp = Nothing 'On libere xlApp
'*************************************************************************************************
' On met à jour la table T_Extraction Donnees Profils Gestion
'*************************************************************************************************
DoCmd.Close acTable, "T_Extraction Donnees Profils Gestion" 'On ferme la table T_Informations Instruments
Call CurrentDb.Execute("DELETE * FROM [T_Extraction Donnees Profils Gestion];")
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "T_Extraction Donnees Profils Gestion", "O:\Portfolio Management\Contrôle et suivi d'activité\Suivi Target Market\Liste Valeurs Profils Gestion LU.xlsx", True |
Partager