Toggles between normal, bold, italic and bold+italic : Selection Format « Excel « VBA / Excel / Access / Word






Toggles between normal, bold, italic and bold+italic

 

Sub ItalicBold()
  Dim bld As Variant, ital As Variant
  If Selection Is Nothing Then Exit Sub
  bld = Selection.Font.Bold: ital = Selection.Font.Italic
  If Not bld And Not ital Then
    bld = True
  ElseIf bld And Not ital Then
    ital = True: bld = False
  ElseIf Not bld And ital Then
    bld = True
  Else
    bld = False: ital = False
  End If
  Selection.Font.Bold = bld: Selection.Font.Italic = ital
End Sub

 








Related examples in the same category

1.Increases font size of the selected cells