Sub Suplignevides () Dim r As Long For = ActiveSheet.UsedRange.Rows.Count To 1 Step - 1 If Application.CountA(.Rows(r)) = 0 Then.Rows(r).Delete Next r End Sub
les lignes vides d'un tableau Word!!!
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionJ'ai créé comme tu me le demandais une macro avec l'enregistreur de macro mais je me suis aperçu que cette macro supprimai les lignes que j'avais sélectionné alors que dans mon cas, je ne connais pas la position des lignes vides.
The VBA code to remove all empty rows and columns from tables:
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(i).Cells If Len(cel.Range.Text) > 2 Then fEmpty = False Exit For End If Next cel If fEmpty = True Then Tbl.Columns(i).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