Home » excel » excel – How to toggle Bold or Italic if a cell is in edit mode?

excel – How to toggle Bold or Italic if a cell is in edit mode?

Posted by: admin May 14, 2020 Leave a comment

Questions:
If Selection.Font.Bold = False Then
Selection.Font.Bold = True
Else
Selection.Font.Bold = False
End If

This works if a range is selected.
How to create the same if a cell is in edit mode, and only a part of its content is selected ?

How to&Answers:

This is what you would use to format parts of a cell, but you can only do this after the edit is complete – like Tim Williams said.

With ActiveCell.Characters(Start:=3, Length:=2).Font
    .Name = "Calibri"
    .Size = 11
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ThemeColor = xlThemeColorLight1
    .TintAndShade = 0
    .ThemeFont = xlThemeFontMinor
End With