0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Excel VBAでセル内文字列の1文字ごとのフォント名を取得する

Posted at

はじめに

日本語版のExcelで文字列を入力していると、記号やギリシャ文字などが勝手に別のフォント(大抵は Calibri、時々Segoe UI Symbol、など)に変わることがあります。単一セルのフォントが変わってしまった場合は直すのも簡単なのですが、場合によっては文章の途中でフォントが変わってしまうこともあります。そこで、セル内の1文字ごとのフォント名を取得してみました。

ワークシート

excel_vba_fontnames_in_cell.jpg

コード

Sub GetFontNamesInCell()
  Dim n
  For n = 1 To Len(ActiveCell.Value)
    Debug.Print n & ": " & ActiveCell.Characters(n, 1).Font.Name
  Next
End Sub

結果

イミディエイト
1: BIZ UDゴシック
2: BIZ UDゴシック
3: BIZ UDゴシック
4: BIZ UDゴシック
5: BIZ UDゴシック
6: BIZ UDゴシック
7: BIZ UDゴシック
8: BIZ UDゴシック
9: BIZ UDゴシック
10: Calibri
11: BIZ UDゴシック
12: Calibri
13: BIZ UDゴシック
14: BIZ UDゴシック
15: BIZ UDゴシック
16: BIZ UDゴシック
17: BIZ UDゴシック
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?