View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
[email protected] hddofut@aol.com is offline
external usenet poster
 
Posts: 2
Default Counting Bordered Cells

On Monday, May 26, 2014 11:50:43 AM UTC-6, Peter T wrote:
wrote in message

...

Complete VBA noob.




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.




Another one, based on Claus' but could be a few times faster be faster with

a large range



Function CountBordersAround(rng As Range) As Long

Dim n As Long

Dim c As Range

n = rng.Count

For Each c In rng

For i = xlEdgeLeft To xlEdgeRight

If c.Borders(i).LineStyle = xlNone Then

n = n - 1

Exit For

End If

Next

Next

CountBordersAround = n

End Function



Regards,

Peter T


Wooot,Thank you Claus and Peter!
Both work well.