VBA that detects conditional formatting

jupasto

New Member
Joined
Aug 19, 2019
Messages
9
Hello,

To preface I'm a total noob with VBA but I found a simple VBA function on the web that tests if a cell is bold or not and returns true or false. I also have some conditional formatting set up to turn text bold if it's within a certain date.

My problem is that even though the conditional formatting works and turns the text bold, the "ISBOLD" function still returns false. Is there a way to modify the VBA to detect the bold text?











Code:
Function ISBOLD(cell As Range) As Boolean

  Application.Volatile True
  On Error GoTo PartiallyBold
    ISBOLD = cell.Characters.Font.Bold
  On Error GoTo 0

Exit Function

PartiallyBold:
  If Err.Number = 94 Then ISBOLD = True

End Function
 
Re: Help with VBA that detects conditional formatting

You could use
Code:
Private Sub Worksheet_Calculate()
   Dim x As Variant
   x = Range("D6:D11").DisplayFormat.Font.Bold
   Range("A12").Value = IIf(x = False, False, True)
End Sub
Which will run whenever any cell on the sheet recaclulates
It needs to go in the relevant sheet module.
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,214,522
Messages
6,120,025
Members
448,939
Latest member
Leon Leenders

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top