Supprimer colonne sous condition

Bonsoir cher tous

Je voudrais supprimer toute colonne si une cellule dans B2:AY2 est =0

J'ai fabriqué ce qui suit mais c’est pas bon apparemment.

Pouvez vous me corriger? MERCI

Sub Macro1()

Dim cell As Range

For Each cell In Range("B2:AY2"):

If cell.Value = 0 Then

cell.Column.Delete

End If

Next cell

End Sub

Bonsoir,

cell.EntireColumn.Delete

?

Bonsoir,

cell.EntireColumn.Delete

?

je fais comme ceci

Mais ça ne marche pas

Sub Macro1()
Dim cell As Range
For Each cell In Range("B2:AY2")
If cell.Value = 0 Then
cell.EntireColumn.Delete
End If
Next cell

End Sub

Salut tout le monde,

ta macro fonctionne chez moi!!

voici une autre macro:

Sub SuprCol()
Dim DerCol As Long
Dim j As Long
Application.ScreenUpdating = False
DerCol = 51 ' dernière colonne AY
For j = DerCol To 2 Step -1 ' de AY à B
    If Cells(2, j)= 0 Then
        Columns(j).Delete
    End If
Next j
Application.ScreenUpdating = True
End Sub

Bonne nuit

Salut tout le monde,

ta macro fonctionne chez moi!!

voici une autre macro:

Sub SuprCol()
Dim DerCol As Long
Dim j As Long
Application.ScreenUpdating = False
DerCol = 51 ' dernière colonne AY
For j = DerCol To 2 Step -1 ' de AY à B
    If Cells(2, j)= 0 Then
        Columns(j).Delete
    End If
Next j
Application.ScreenUpdating = True
End Sub

Bonne nuit

Merci

Rechercher des sujets similaires à "supprimer colonne condition"