Bonjour,
A tester.
Cdlt.
Option Explicit
'http://forum.excel-pratique.com/excel/convertir-des-donnees-pdf-en-excel-t73531.html
Public Sub ConsolidateData()
Dim wb As Workbook
Dim ws As Worksheet
Dim tbl As Variant, Arr() As String
Dim lastRow As Long, lastCol As Long, I As Long, J As Long
Dim k As Long
Dim c As Range, rng As Range, Urng As Range
Const x As String = "____"
Const y As String = "*-*"
Dim firstAddress As String
Dim ModeCalc As XlCalculation
With Application
ModeCalc = .Calculation
.DisplayAlerts = False
'.EnableEvents = False
.ScreenUpdating = False
End With
Set wb = ActiveWorkbook
Set ws = wb.Worksheets(1)
lastCol = ws.Cells(1, Columns.Count).End(xlToLeft).Column
ws.Rows("1:3").Delete
lastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
With ws.Range("A1:A" & lastRow)
Set c = .Find(what:=Chr(12), LookIn:=xlValues, Lookat:=xlWhole)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Set rng = c.Resize(4, lastCol)
If Urng Is Nothing Then
Set Urng = rng
Else
Set Urng = Union(Urng, rng)
End If
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
If Not Urng Is Nothing Then Urng.Delete shift:=xlShiftUp
Set Urng = Nothing: Set rng = Nothing
lastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = ws.Cells(1).Resize(lastRow, lastCol) _
.SpecialCells(xlCellTypeConstants, xlTextValues)
With rng
.Replace x, vbNullString
.Replace y, vbNullString
End With
Set rng = Nothing
Set rng = ws.UsedRange.SpecialCells(xlCellTypeBlanks)
rng.Delete shift:=xlShiftUp
tbl = ws.Cells(1).CurrentRegion.Value
k = 0
For I = 1 To UBound(tbl, 1)
For J = 1 To UBound(tbl, 2)
ReDim Preserve Arr(1, k + 1)
Arr(0, k) = tbl(I, J)
k = k + 1
Next J
Next I
ws.Cells.Clear
ws.[A1].Resize(UBound(Arr, 2), 1) = Application.Transpose(Arr)
ws.Cells(1).CurrentRegion.NumberFormat = "0000"
ws.[A1].CurrentRegion.Sort _
key1:=ws.[A1], _
order1:=xlAscending, _
Header:=xlGuess
With Application
.Calculation = ModeCalc
.DisplayAlerts = True
'.EnableEvents = True
.ScreenUpdating = True
End With
Erase Arr()
Set rng = Nothing
Set ws = Nothing
Set wb = Nothing
End Sub