回答編集履歴
1
trimを用いるよう修正
answer
CHANGED
@@ -11,4 +11,20 @@
|
|
11
11
|
```
|
12
12
|
|
13
13
|
なお求めておられる回答から多少ずれますが、やりたいこととして、もしかするとVBAを用いなくても条件付き書式で簡単に実現できませんか?
|
14
|
-
[参考リンク](http://www.becoolusers.com/excel/conditional-formatting.html)
|
14
|
+
[参考リンク](http://www.becoolusers.com/excel/conditional-formatting.html)
|
15
|
+
|
16
|
+
追記
|
17
|
+
Trimを使ってみます。[参考リンク](http://officetanaka.net/excel/vba/function/Trim.htm)
|
18
|
+
|
19
|
+
```VBA
|
20
|
+
Private Sub Worksheet_Change(ByVal Target As Range)
|
21
|
+
Dim value As String
|
22
|
+
|
23
|
+
value = Cells(Target.Row, Target.Column).Value
|
24
|
+
|
25
|
+
If Trim(value) <> "" Then
|
26
|
+
Cells(Target.Row + 1, Target.Column).Interior.Color = RGB(255, 0, 0)
|
27
|
+
End If
|
28
|
+
|
29
|
+
End Sub
|
30
|
+
```
|