compter nombre de cellule avec prix barré en VBA

nicroq

XLDnaute Occasionnel
Bonjour a tous et merci pour votre aide,

je souhaiterai faire par VBA le calcul du nombre de cellules ayant un prix barré ?

merci

bonne journée
 

Pièces jointes

  • prix barré.xlsx
    8.3 KB · Affichages: 7

gilbert_RGI

XLDnaute Barbatruc
Re : compter nombre de cellule avec prix barré en VBA

Bonjour,

avec ceci !

VB:
Sub test()
    Dim Cel As Range
    For Each Cel In Worksheets("feuil1").UsedRange
        Cel.Select
        If Cel <> "" And Selection.Font.Strikethrough = True Then x = x + 1
    Next
    MsgBox x
End Sub
 
Dernière édition:

nicroq

XLDnaute Occasionnel
Re : compter nombre de cellule avec prix barré en VBA

merci pour votre reponse rapide!
cependant quand je l integre dans mon fichier dans un module sous forme de fonction cela ne marche pas..

pourriez vous maider?

merci
cdlt
 

gilbert_RGI

XLDnaute Barbatruc
Re : compter nombre de cellule avec prix barré en VBA

comme ceci
VB:
Function nbarré(champ As Range)
    Application.Volatile
    nbarré = 0
    For Each Cel In champ
        If Cel <> "" And Cel.Font.Strikethrough = True Then
            nbarré = nbarré + 1
        End If
    Next Cel
End Function
 

Discussions similaires

Réponses
2
Affichages
258
  • Question
Microsoft 365 TCD
Réponses
12
Affichages
370

Statistiques des forums

Discussions
312 764
Messages
2 091 859
Membres
105 080
dernier inscrit
mellusine83