Thread
:
Counting Bordered Cells
View Single Post
#
4
Posted to microsoft.public.excel.programming
Claus Busch
external usenet poster
Posts: 3,872
Counting Bordered Cells
Hi,
Am Mon, 26 May 2014 08:25:39 -0700 (PDT) schrieb
:
When I run the function I do receive a result, but it is not accurate. IT may be counting the cells that have a left border by default.
This may be helpful, by default the range will have the top and left cell already with a border. I need to count the cells in the range when they have all four sides bordered.
yes, you are right
Try:
Function CountBrd(myRng As Range) As Long
Dim rngC As Range
Dim i As Long
For Each rngC In myRng
If rngC.Borders(xlEdgeLeft).LineStyle < xlNone _
And rngC.Borders(xlEdgeBottom).LineStyle < xlNone _
And rngC.Borders(xlEdgeRight).LineStyle < xlNone _
And rngC.Borders(xlEdgeTop).LineStyle < xlNone Then
i = i + 1
End If
Next
CountBrd = i
End Function
Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
Reply With Quote
Claus Busch
View Public Profile
Find all posts by Claus Busch