Forum Discussion
counting cells with left border
Hi Bill,
If you have a conditional formatting rule to generate cell borders based on a certain condition, you can use this condition in a COUNTIFS formula.
If you wish to count cells directly formatted with a left border, you would have to use a user defined function to count the cells. Here is my example:
---------------------------------------------------------------
Public Function COUNLEFTBORDERS(MyRange As Range) As Integer
Dim iBorderCount As Integer
Dim c As Variant
For Each c In MyRange
If c.Borders(xlEdgeLeft).LineStyle <> xlLineStyleNone Then
iBorderCount = iBorderCount + 1
End If
Next c
COUNLEFTBORDERS = iBorderCount
End Function
----------------------------------------------------------------------
Please place it into a VBA module.
If you put your range with some left borders into B5:B14, the formula would be =COUNLEFTBORDERS(B5:B14).
Hope it helps
Yury