Thread
:
Counting Bordered Cells
View Single Post
#
2
Posted to microsoft.public.excel.programming
Claus Busch
external usenet poster
Posts: 3,872
Counting Bordered Cells
Hi,
Am Sun, 25 May 2014 21:06:37 -0700 (PDT) schrieb
:
I have created a module in VBA and have tried the following to count cells in a range on one sheet that have four sides bordered and have the count results in a cell on another sheet.
Line style and color do not matter.
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 Then
i = i + 1
End If
Next
CountBrd = WorksheetFunction.RoundUp(i / 2, 0)
End Function
and call this function into the sheet with:
=CountBrd(A1:E15)
or from another sheet with:
=CountBrd(Sheet2!A1:E15)
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