如果单元格处于编辑模式,如何切换粗体或斜体?

时间:2012-09-26 15:39:50

标签: excel vba

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

如果选择范围,则此方法有效 如果单元格处于编辑模式,并且只选择了其中一部分内容,如何创建相同的内容?

1 个答案:

答案 0 :(得分:3)

这是你用来格式化单元格部分的方法,但你只能在编辑完成后才能这样做 - 就像蒂姆·威廉姆斯所说的那样。

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