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
| Sub Macro1()
'
' Macro1 Macro
'
'
Dim Fichier As String
Dim selec As FileDialog 'création de la boite de dialogue
Set selec = Application.FileDialog(msoFileDialogOpen) 'préparation de la boite de dialogue
selec.Title = "Sélectionnez le fichier à utiliser"
selec.AllowMultiSelect = False 'on ne souhaite qu'un seul fichier
selec.Filters.Add "fichiers CSV", "*.csv" 'on ne prend que les fichiers CSV
selec.Show 'affichage de la boite
Fichier = selec.SelectedItems(1)
With ActiveSheet.QueryTables.Add(Connection:=Fichier, Destination:=Range("A1"))
.Name = "releve (16)"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlMacintosh
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.Refresh BackgroundQuery:=False
.UseListObject = False
End With
Range("A1:I24").Select
Selection.Delete Shift:=xlToLeft
Range("J1:J25").Select
Selection.Delete Shift:=xlToLeft
Range("E1:H25").Select
Range("H25").Activate
Selection.Delete Shift:=xlToLeft
Range("B1:C25").Select
Selection.Delete Shift:=xlToLeft
Dim i As Integer
Dim j As Integer
Dim longueur As Long
Dim longueur2 As Long
longueur2 = 100
longueur = 100
For i = longueur To 1 Step -1
If IsEmpty(Cells(i, 2)) Or IsEmpty(Cells(i, 3)) Then
Cells(i - 1, 2).Value = Cells(i - 1, 2).Value & vbCr & Cells(i, 2).Value
Rows(i).Delete
End If
Next i
For j = longueur To 1 Step -1
If Cells(j, 2) = " " Then
Rows(j).Delete
End If
Next j
ChDir "Macintosh HD:Users:Desktop:"
End Sub |
Partager