Forum Discussion
_Carter16
Jul 13, 2023Copper Contributor
Excel
I'm trying to make it so when I use the font effect "strikethrough" on a number it is then not counted in a SUM function.
You might use the following VBA function:
Function SumNotStrikethrough(rng As Range) As Double Dim cel As Range Application.Volatile For Each cel In rng If Not cel.Font.Strikethrough Then SumNotStrikethrough = SumNotStrikethrough + Val(cel.Value) End If Next cel End Function
Use like this in a cell formula:
=SumNotStrikethrough(A2:A10)
Warning: applying strikethrough to a cell or removing it will not cause the result of the formula to be updated automatically. It will be updated the next time Excel recalculates any formula. You can force this by pressing F9.
That's with VBA programming only