Bonjour,
J'ai un long tableau avec des mot et des définitions.
Il se vérifie que l'une ou l'autre cellule soit vide.
Par VBA je voudrais éliminer la ligne entière si l'une des 2 cellules (colonne 1 ou colonne 2) est vide.
J'ai trouvé ce code mais en réalité il élimine la ligne uniquement si les 2 cellules sont vides en même temps.
Est-ce que quelqu'un pourrais m'aider?
Bonne journée
Luca
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Sub DeleteEmptyTablerowsandcolumns() 'Application.ScreenUpdating = False Dim Tbl As Table, cel As Cell, i As Long, n As Long, fEmpty As Boolean With ActiveDocument For Each Tbl In .Tables n = Tbl.Columns.Count For i = n To 1 Step -1 fEmpty = True For Each cel In Tbl.Columns(1).Cells If Len(cel.Range.Text) > 2 Then fEmpty = False Exit For End If Next cel If fEmpty = True Then Tbl.Columns(1).Delete Next i Next Tbl End With With ActiveDocument For Each Tbl In .Tables n = Tbl.Rows.Count For i = n To 1 Step -1 fEmpty = True For Each cel In Tbl.Rows(i).Cells If Len(cel.Range.Text) > 2 Then fEmpty = False Exit For End If Next cel If fEmpty = True Then Tbl.Rows(i).Delete Next i Next Tbl End With Set cel = Nothing: Set Tbl = Nothing Application.ScreenUpdating = True End Sub
Partager