回答編集履歴
1
追記
answer
CHANGED
@@ -1,4 +1,47 @@
|
|
1
1
|
[Excelファイルに入力中のフォントが強制的に游ゴシックへ変わる](https://answers.microsoft.com/ja-jp/msoffice/forum/msoffice_excel-mso_win10-mso_2016/excel%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AB/c38e44a5-bd6c-46b6-bd28-9fcd32fdcafa)
|
2
2
|
|
3
3
|
↑これじゃないですかね?
|
4
|
-
最新のバージョンにアップデートしたら、なおるかも?
|
4
|
+
最新のバージョンにアップデートしたら、なおるかも?
|
5
|
+
|
6
|
+
コードの方はこんな感じでまとめてみてはいかがでしょうか。
|
7
|
+
```ExcelVBA
|
8
|
+
Option Explicit
|
9
|
+
|
10
|
+
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
|
11
|
+
Dim rngEventArea As Range: Set rngEventArea = Me.Range("C3:F10")
|
12
|
+
Dim c As Range
|
13
|
+
|
14
|
+
Set Target = Intersect(Target.Resize(, 1), rngEventArea)
|
15
|
+
If Target Is Nothing Then Exit Sub
|
16
|
+
|
17
|
+
For Each c In Target.Cells
|
18
|
+
CheckOnOff c
|
19
|
+
Next
|
20
|
+
|
21
|
+
rngEventArea(0, 1).Select
|
22
|
+
End Sub
|
23
|
+
|
24
|
+
Private Sub CheckOnOff(ByRef c As Range)
|
25
|
+
Dim cmyTrue As String: cmyTrue = ChrW(9745)
|
26
|
+
Dim cmyFalse As String: cmyFalse = ChrW(9744)
|
27
|
+
Dim cDefault As String: cDefault = ChrW(9744) & "リハ"
|
28
|
+
Dim s As String
|
29
|
+
Dim flg As Boolean
|
30
|
+
|
31
|
+
If c.Font.Color = rgbLightSlateGray Then Exit Sub
|
32
|
+
s = c.Value
|
33
|
+
flg = CBool(InStr(s, cmyFalse))
|
34
|
+
If flg Then
|
35
|
+
s = Replace(s, cmyFalse, cmyTrue)
|
36
|
+
Else
|
37
|
+
s = Replace(s, cmyTrue, cmyFalse)
|
38
|
+
End If
|
39
|
+
c.Value = s
|
40
|
+
If CBool(c.Column Mod 2) Then
|
41
|
+
With c.Offset(, 1)
|
42
|
+
.Value = cDefault
|
43
|
+
.Font.Color = IIf(flg, vbBlack, rgbLightSlateGray)
|
44
|
+
End With
|
45
|
+
End If
|
46
|
+
End Sub
|
47
|
+
```
|