Colonne ne contient que...

Excel_Cupidon

XLDnaute Nouveau
Bonjour,

Je possède un fichier Excel qui contient des colonnes à en-têtes et dont les valeurs peuvent être "true" ou "false".
J'aimerais supprimer les colonnes qui contiennent uniquement des "true" (hors en-tête).
Avez-vous une solution SVP ?

Merci d'avance
 

DoubleZero

XLDnaute Barbatruc
Re-bonjour,

Comme ceci ?
VB:
Option Explicit
Sub True_supprimer()
    Dim c As Range, maxi As Long
    With Application: .ScreenUpdating = False: .Calculation = xlManual: .EnableEvents = False: End With
    Rows("1:2").Insert
    For Each c In Rows("3:3").SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants)
        c.Offset(-2, 0).FormulaR1C1 = "=COUNTIF(R[3]C:R[40]C,""true"")"
        c.Offset(-1, 0).FormulaR1C1 = "=COUNTA(R[1]C:R[229]C)-1"
    Next
    maxi = Application.Max(Rows("2:2"))
    For Each c In Rows("1:1").SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeFormulas)
        If c.Value = maxi Then c.Offset(3, 0).Resize(1000000).Clear
    Next
    Rows("1:2").Delete
    With Application: .EnableEvents = True: .Calculation = xlAutomatic: .ScreenUpdating = True: End With
End Sub
A bientôt :)
 

phlaurent55

Nous a quittés en 2020
Repose en paix
Bonjour à toutes et tous,

mon interprétation de la question posée:

Code:
For i = Range("IV1").End(xlToLeft).Column To 2 Step -1
If Application.WorksheetFunction.CountIf(Range(Cells(2, i), Cells(Range("A66535").End(xlUp).Row, i)), "t*") = Range("A66535").End(xlUp).Row - 1 Then Columns(i).Delete
Next i

à+
Philippe
 

Statistiques des forums

Discussions
312 206
Messages
2 086 207
Membres
103 158
dernier inscrit
laufin