ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Logical test if cell uses formatting.. (https://www.excelbanter.com/excel-worksheet-functions/164931-logical-test-if-cell-uses-formatting.html)

Mac

Logical test if cell uses formatting..
 
Is there a logical test to check if, for example, a cell contents is in bold?

John Bundy

Logical test if cell uses formatting..
 
As far as I know there is nothing built in, I built this function for someone
that counts cells that are bold, you can use it or modify, I can help you
modify it to your purpose if you need to. It goes in a module, preferably in
your personal.xls.

Function CountBold(rRange As Range) As Long
Dim lCount As Long, myCell As Range
lCount = 0
For Each myCell In rRange
If myCell.Font.bold = True Then
lCount = lCount + 1
End If
Next myCell
CountBold = lCount
End Function
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Mac" wrote:

Is there a logical test to check if, for example, a cell contents is in bold?


JE McGimpsey

Logical test if cell uses formatting..
 
Note that changing the formatting within rRange doesn't cause this to
recalculate. You could add

Application.Volatile

after the Dim statement, but you'd still need to manually calculate the
sheet to ensure that the result is correct.



In article ,
John Bundy (remove) wrote:

As far as I know there is nothing built in, I built this function for someone
that counts cells that are bold, you can use it or modify, I can help you
modify it to your purpose if you need to. It goes in a module, preferably in
your personal.xls.

Function CountBold(rRange As Range) As Long
Dim lCount As Long, myCell As Range
lCount = 0
For Each myCell In rRange
If myCell.Font.bold = True Then
lCount = lCount + 1
End If
Next myCell
CountBold = lCount
End Function



All times are GMT +1. The time now is 07:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com