PC Review


Reply
Thread Tools Rate Thread

count cells with diagonal borders

 
 
jt
Guest
Posts: n/a
 
      25th Sep 2011
Hi,
I have some code that counts cells with specific color, now I also
want to count all cells with diagonal borders. The cell color count
VBA is below...

Function CellColorIndex(InRange As Range, Optional _
OfText As Boolean = False) As Integer
'
' This function returns the ColorIndex value of a the Interior
' (background) of a cell, or, if OfText is true, of the Font in the
cell.
'
Application.Volatile True
If OfText = True Then
CellColorIndex = InRange(1, 1).Font.ColorIndex
Else
CellColorIndex = InRange(1, 1).Interior.ColorIndex
End If


End Function


Function CountByColor(InRange As Range, _
WhatColorIndex As Integer, _
Optional OfText As Boolean = False) As Long
'
' This function return the number of cells in InRange with
' a background color, or if OfText is True a font color,
' equal to WhatColorIndex.
'
Dim Rng As Range
Application.Volatile True


For Each Rng In InRange.Cells
If OfText = True Then
CountByColor = CountByColor - _
(Rng.Font.ColorIndex = WhatColorIndex)
Else
CountByColor = CountByColor - _
(Rng.Interior.ColorIndex = WhatColorIndex)
End If
Next Rng


End Function


any help is appreciated as usual...thankyou.



 
Reply With Quote
 
 
 
 
Gord
Guest
Posts: n/a
 
      25th Sep 2011
See answer from Sept 11th

http://tinyurl.com/6b222hv



Gord Dibben Microsoft Excel MVP

On Sat, 24 Sep 2011 19:07:20 -0700 (PDT), jt <(E-Mail Removed)>
wrote:

>Hi,
>I have some code that counts cells with specific color, now I also
>want to count all cells with diagonal borders. The cell color count
>VBA is below...
>
>Function CellColorIndex(InRange As Range, Optional _
> OfText As Boolean = False) As Integer
>'
>' This function returns the ColorIndex value of a the Interior
>' (background) of a cell, or, if OfText is true, of the Font in the
>cell.
>'
>Application.Volatile True
>If OfText = True Then
> CellColorIndex = InRange(1, 1).Font.ColorIndex
>Else
> CellColorIndex = InRange(1, 1).Interior.ColorIndex
>End If
>
>
>End Function
>
>
>Function CountByColor(InRange As Range, _
> WhatColorIndex As Integer, _
> Optional OfText As Boolean = False) As Long
>'
>' This function return the number of cells in InRange with
>' a background color, or if OfText is True a font color,
>' equal to WhatColorIndex.
>'
>Dim Rng As Range
>Application.Volatile True
>
>
>For Each Rng In InRange.Cells
>If OfText = True Then
> CountByColor = CountByColor - _
> (Rng.Font.ColorIndex = WhatColorIndex)
>Else
> CountByColor = CountByColor - _
> (Rng.Interior.ColorIndex = WhatColorIndex)
>End If
>Next Rng
>
>
>End Function
>
>
>any help is appreciated as usual...thankyou.
>
>

 
Reply With Quote
 
jt
Guest
Posts: n/a
 
      26th Sep 2011
On Sep 24, 10:20*pm, Gord <phnor...@shaw.ca> wrote:
> See answer from Sept 11th
>
> http://tinyurl.com/6b222hv
>
> Gord Dibben * *Microsoft Excel MVP
>
> On Sat, 24 Sep 2011 19:07:20 -0700 (PDT), jt <kijij...@gmail.com>
> wrote:
>
>
>
> >Hi,
> >I have some code that counts cells with specific color, now I also
> >want to count all cells with diagonal borders. The cell color count
> >VBA is below...

>
> >Function CellColorIndex(InRange As Range, Optional _
> > * *OfText As Boolean = False) As Integer
> >'
> >' This function returns the ColorIndex value of a the Interior
> >' (background) of a cell, or, if OfText is true, of the Font in the
> >cell.
> >'
> >Application.Volatile True
> >If OfText = True Then
> > * *CellColorIndex = InRange(1, 1).Font.ColorIndex
> >Else
> > * *CellColorIndex = InRange(1, 1).Interior.ColorIndex
> >End If

>
> >End Function

>
> >Function CountByColor(InRange As Range, _
> > * *WhatColorIndex As Integer, _
> > * *Optional OfText As Boolean = False) As Long
> >'
> >' This function return the number of cells in InRange with
> >' a background color, or if OfText is True a font color,
> >' equal to WhatColorIndex.
> >'
> >Dim Rng As Range
> >Application.Volatile True

>
> >For Each Rng In InRange.Cells
> >If OfText = True Then
> > * *CountByColor = CountByColor - _
> > * * * * * *(Rng.Font.ColorIndex = WhatColorIndex)
> >Else
> > * *CountByColor = CountByColor - _
> > * * * (Rng.Interior.ColorIndex = WhatColorIndex)
> >End If
> >Next Rng

>
> >End Function

>
> >any help is appreciated as usual...thankyou.- Hide quoted text -

>
> - Show quoted text -


this works, thankyou
 
Reply With Quote
 
isabelle
Guest
Posts: n/a
 
      26th Sep 2011
attention this formula does not automatically recalculate if you delete or add a diagonal in the range of target cells

--
isabelle



Le 2011-09-25 19:55, jt a écrit :

> this works, thankyou

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
count cells with diagonal borders jt Microsoft Excel Programming 3 26th Sep 2011 12:55 AM
count cells with diagonal cell borders jt Microsoft Excel Programming 0 3rd May 2011 03:02 PM
Diagonal Borders Rosi Microsoft Excel Misc 3 28th Oct 2008 07:13 PM
Creating cells with Diagonal borders =?Utf-8?B?R3JhaGFtIFRyaXR0b24=?= Microsoft Excel Misc 1 24th Jan 2006 06:09 AM
Count Problem- cells with diagonal line SKF Adam Microsoft Excel Discussion 3 28th Apr 2004 01:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:11 AM.