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
| 'Mise en page du tableau en supprimant les lignes vides, titres intercalaires,interlignes et images et défusionnant les cellules
Sub Misenpage()
Dim feuil As Worksheet
Dim Rg As Range, Rg1 As Range
Dim Expression As String
Dim i As Long
Expression1 = ""
Expression2 = "A-NOMENCLATURE DES INSTALLATIONS CLASSEES"
UserForm1.Show 0
UserForm1.Repaint
With Worksheets("Legifrance") 'Nom de la feuille à adapter
Set Rg = .Cells.Find(what:=Expression1, LookIn:=xlValues, lookat:=xlWhole)
Set Rg1 = .Cells.Find(what:=Expression2, LookIn:=xlValues, lookat:=xlWhole)
If Not Rg Is Nothing Then
'Supprime la plage de cellules
.Range(Rg, Rg1).EntireRow.Delete
End If
'Sauvegarder la barre d'état en place
Barre_Actuelle = Application.DisplayStatusBar
Application.DisplayStatusBar = True
'affichage de la barre avec le message
Application.StatusBar = "Mise en page en cours dexécution, veuillez patienter"
'Traitement à faire
For i = Range("A" & Rows.Count).End(xlUp).Row To 10 Step -1
If Cells(i, 2) = "" Then
Cells(i, 2).EntireRow.Delete
End If
If Cells(i, 2) = "A-NOMENCLATURE DES INSTALLATIONS CLASSEES" Then
Cells(i, 2).EntireRow.Delete
End If
If Cells(i, 2) = "Désignation de la rubrique" Then
Cells(i, 2).EntireRow.Delete
End If
If Cells(i, 3).MergeCells Then
Cells(i, 3).MergeCells = False
End If
If Cells(i, 4).MergeCells Then
Cells(i, 4).MergeCells = False
End If
Application.StatusBar = "Lignes en cours de mise en page : " & i
Progressbarre i, Range("A" & Rows.Count).End(xlUp).Row
Next i
'message de fin
Application.StatusBar = "Traitement fini, Merci de votre patience"
'3 secondes d'attente
Application.Wait Now + TimeValue("00:00:05")
'restauration de l'état de départ
Application.StatusBar = False
Application.DisplayStatusBar = Barre_Actuelle
Unload UserForm1
End With
End Sub |
Partager