Change only bullet font color

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Change only bullet font color

Post by ABabeNChrist »

I need a little assistance. I sometimes add a billet at the start of a sentence and I was trying to use conditional formatting so that ONLY the billet font would turn red when ever used for either each sheet or entire workbook. Any suggestions greatly appreciated. I know how to select the billet and change the color manually; I was just trying to find an automatic way
Last edited by HansV on 22 Oct 2016, 13:21, edited 1 time in total.
Reason: to edit the subject (billet > bullet)

User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Change only billet font color

Post by HansV »

Do you mean bullet?
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Change only billet font color

Post by HansV »

If you mean bullet: conditional formatting applies to a cell as a whole, not to individual characters in a cell.
It might be possible to use VBA code to format bullets, but that might not be desirable: VBA code tends to disable Excel's undo feature.
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Change only billet font color

Post by ABabeNChrist »

HansV wrote:Do you mean bullet?
Sorry, yes I meant bullet :grin:

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Change only billet font color

Post by ABabeNChrist »

HansV wrote:If you mean bullet: conditional formatting applies to a cell as a whole, not to individual characters in a cell.
It might be possible to use VBA code to format bullets, but that might not be desirable: VBA code tends to disable Excel's undo feature.
Thank you

User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Change only billet font color

Post by HansV »

Also, the code would only work for cells in which you enter a value, not for cells with a formula.
Would you like to have the VBA code, or will you work it our yourself?
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Change only billet font color

Post by ABabeNChrist »

HansV wrote:Also, the code would only work for cells in which you enter a value, not for cells with a formula.
Would you like to have the VBA code, or will you work it our yourself?
Yes coding sounds good as I do not use formula's, only VBA and conditional formatting

User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Change only bullet font color

Post by HansV »

For one sheet:

Right-click the sheet tab.
Select View Code from the context menu.
Copy the following code into the worksheet module:

Code: Select all

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cel As Range
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    For Each cel In Target
        If Left(cel.Value, 1) = Chr(149) And Not cel.HasFormula Then
            cel.Characters(1, 1).Font.Color = vbRed
        End If
    Next cel
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub
Remarks:

1) If you already have code in the Worksheet_Change event procedure, you must add the above code (except for the Private Sub and End Sub lines) to the existing event procedure, preferably at the beginning. It is not allowed to have multiple Worksheet_Change event procedures for the same worksheet.
2) If the worksheet is protected, you must unprotect it at the beginning of the code, and reprotect it at the end.

For the entire workbook:

Activate the Visual Basic Editor.
Double-click ThisWorkbook.
Copy the following code into the ThisWorkbook module:

Code: Select all

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim cel As Range
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    For Each cel In Target
        If Left(cel.Value, 1) = Chr(149) And Not cel.HasFormula Then
            cel.Characters(1, 1).Font.Color = vbRed
        End If
    Next cel
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub
The same remarks as above apply.
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Change only bullet font color

Post by ABabeNChrist »

Your awesome, thanks Hans