Private Sub Worksheet_Activate()
Dim col%, i&, tablo, x$, p%
Application.ScreenUpdating = False
Sheets("Import").Cells.Copy Cells(1) 'copier-coller de toute la feuille
With ListObjects(1) 'tableau structuré
.TableStyle = "TableStyleMedium3" 'le style que vous voulez
With .Range
.Rows(1).Insert xlDown: .Rows(1).Copy .Rows(0): .Rows(1).Hidden = True 'insère la nouvelle ligne de titres
.Rows(2).Insert xlDown: .Rows(0).EntireRow.Copy .Rows(2): .Rows(2).ClearContents 'insère la ligne des sous-titres
For col = .Columns.Count To 4 Step -1
.Columns(col).Resize(, 3).EntireColumn.Insert 'insère 3 colonnes
.Cells(0, col).Resize(, 3).Merge: .Cells(0, col) = .Cells(1, col + 3)
.Cells(2, col).Resize(, 3) = Array("HT", "TVA", "TTC")
tablo = .Columns(col).Resize(, 4) 'matrice, plus rapide
For i = 3 To UBound(tablo)
x = tablo(i, 4)
p = InStr(x, "HT"): If p Then tablo(i, 1) = Val(Replace(Replace(Replace(Mid(x, p + 2), Chr(160), ""), ":", ""), ",", "."))
p = InStr(x, "TVA"): If p Then tablo(i, 2) = Val(Replace(Replace(Replace(Mid(x, p + 3), Chr(160), ""), ":", ""), ",", "."))
p = InStr(x, "TTC"): If p Then tablo(i, 3) = Val(Replace(Replace(Replace(Mid(x, p + 3), Chr(160), ""), ":", ""), ",", "."))
Next i
.Columns(col).Resize(, 3) = tablo 'restitution
.Columns(col + 3).EntireColumn.Delete
Next col
'---formats---
With Union(.Rows(0), .Cells)
.Borders.Weight = xlThin
For col = 1 To .Columns.Count Step 3: .Columns(col).Resize(, 3).BorderAround Weight:=xlMedium: Next col
End With
.Rows(0).Resize(3, 3).Borders(xlInsideHorizontal).Color = .Rows(0).Interior.Color 'pour masquer la bordure
With Union(.Cells(0, 4), .Columns(4)).Resize(, .Columns.Count - 3)
.HorizontalAlignment = xlCenter
.ColumnWidth = 12.5
.NumberFormat = "#,##0.00 €"
End With
.Rows("3:" & .Rows.Count).AutoFit 'ajustement hauteurs
With .Parent.UsedRange: End With 'ajuste les barres de défilement
.Rows(0).Select: ActiveWindow.Zoom = True 'ajuste le zoom
Application.Goto .Cells(0, 1), True 'cadrage
End With
End With
With ActiveWindow: .FreezePanes = False: .SplitRow = 3: .FreezePanes = True: End With 'fige les volets
End Sub