回答編集履歴
1
コード追記
test
CHANGED
@@ -40,9 +40,67 @@
|
|
40
40
|
|
41
41
|
Range("B1").Value = Null
|
42
42
|
|
43
|
-
|
43
|
+
End Select
|
44
44
|
|
45
|
+
End With
|
46
|
+
|
47
|
+
Application.EnableEvents = True
|
48
|
+
|
49
|
+
End If
|
50
|
+
|
51
|
+
End Sub
|
52
|
+
|
53
|
+
```
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
---
|
58
|
+
|
59
|
+
> 追加の質問で申し訳ないのですが、ドロップダウン1でBを選択した時、B1のセルを入力禁止にすることは可能でしょうか。
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
セルのロックとシートの保護を使えばいいでしょう。
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
```vba
|
70
|
+
|
71
|
+
Private Sub Worksheet_Change(ByVal Target As Range)
|
72
|
+
|
73
|
+
If Not Intersect(Target, Range("A1")) Is Nothing Then
|
74
|
+
|
75
|
+
Application.EnableEvents = False
|
76
|
+
|
77
|
+
If ProtectContents Then Unprotect Password:="1234"
|
78
|
+
|
79
|
+
Cells.Locked = False
|
80
|
+
|
81
|
+
With Range("B1").Validation
|
82
|
+
|
83
|
+
.Delete
|
84
|
+
|
45
|
-
|
85
|
+
Select Case Range("A1").Value
|
86
|
+
|
87
|
+
Case "A"
|
88
|
+
|
89
|
+
.Add Type:=xlValidateList, _
|
90
|
+
|
91
|
+
Operator:=xlEqual, _
|
92
|
+
|
93
|
+
Formula1:="CCC,DDD,EEE"
|
94
|
+
|
95
|
+
Range("B1").Locked = False
|
96
|
+
|
97
|
+
Case "B"
|
98
|
+
|
99
|
+
Range("B1").Value = Null
|
100
|
+
|
101
|
+
Range("B1").Locked = True
|
102
|
+
|
103
|
+
Protect Password:="1234"
|
46
104
|
|
47
105
|
End Select
|
48
106
|
|
@@ -54,6 +112,4 @@
|
|
54
112
|
|
55
113
|
End Sub
|
56
114
|
|
57
|
-
|
58
|
-
|
59
115
|
```
|