質問編集履歴
2
インシデント追加しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,7 +3,23 @@
|
|
3
3
|
変数dは、どちらも正しく読み込まれておりますが、前者でのみcell(x,7).valueの値が読み込まれず、dのままの数値になります。
|
4
4
|
わかりずらい説明で申し訳ありませんがどなたか解決方法を教えていただきたいです。
|
5
5
|
|
6
|
+
#インシデント
|
7
|
+
例えば下記の部分であれば、cells(9,7)のセルの数値+dをcells(9,8)に出力するというものですが
|
8
|
+
ボタンを押したときの場合、dのみの値になってしまっています。
|
9
|
+
コード入力の実行の部分であれば問題なく作動します。
|
6
10
|
```vba
|
11
|
+
Dim d As Integer
|
12
|
+
|
13
|
+
d = Cells(Cells(9, 15).Value + 1, 2).Value
|
14
|
+
|
15
|
+
Cells(9, 8).Value = Cells(9, 7).Value + d
|
16
|
+
Cells(10, 8).Value = Cells(10, 7).Value + d
|
17
|
+
Cells(11, 8).Value = Cells(11, 7).Value + d
|
18
|
+
Cells(12, 8).Value = Cells(12, 7).Value + d
|
19
|
+
|
20
|
+
```
|
21
|
+
|
22
|
+
```vba
|
7
23
|
Sub ボタン1_Click()
|
8
24
|
|
9
25
|
If Cells(9, 13) = "1" Then
|
1
変数bはdでした。失礼いたしました。sheet1がアクティブかと思います。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,118 +1,117 @@
|
|
1
1
|
vbaにて、ボタンを押したときの結果 と コード入力部分の実行 を押したときの動作が異なります。
|
2
2
|
結果的には、後者の入力のときは正しく入力されます。
|
3
|
-
変数
|
3
|
+
変数dは、どちらも正しく読み込まれておりますが、前者でのみcell(x,7).valueの値が読み込まれず、dのままの数値になります。
|
4
4
|
わかりずらい説明で申し訳ありませんがどなたか解決方法を教えていただきたいです。
|
5
5
|
|
6
|
+
```vba
|
6
7
|
Sub ボタン1_Click()
|
7
8
|
|
8
9
|
If Cells(9, 13) = "1" Then
|
9
10
|
|
10
|
-
|
11
|
+
Dim d As Integer
|
11
12
|
|
12
|
-
|
13
|
+
d = Cells(Cells(9, 15).Value + 1, 2).Value
|
13
14
|
|
14
|
-
|
15
|
+
Cells(9, 8).Value = Cells(9, 7).Value + d
|
15
|
-
|
16
|
+
Cells(10, 8).Value = Cells(10, 7).Value + d
|
16
|
-
|
17
|
+
Cells(11, 8).Value = Cells(11, 7).Value + d
|
17
|
-
|
18
|
+
Cells(12, 8).Value = Cells(12, 7).Value + d
|
18
|
-
|
19
|
+
|
19
|
-
|
20
|
+
Call fanc1
|
20
|
-
|
21
|
+
|
21
22
|
ElseIf Cells(9, 13) = "2" Then
|
22
|
-
|
23
|
-
p = Cells(Cells(9, 13).Value + 1, 2).Value
|
24
|
-
d = Cells(Cells(9, 15).Value + 1, 2).Value
|
25
23
|
|
26
|
-
Cells(9,
|
24
|
+
p = Cells(Cells(9, 13).Value + 1, 2).Value
|
27
|
-
Cells(
|
25
|
+
d = Cells(Cells(9, 15).Value + 1, 2).Value
|
28
|
-
Cells(14, 8).Value = Cells(14, 7).Value + d
|
29
|
-
Cells(15, 8).Value = Cells(15, 7).Value + d
|
30
|
-
|
31
|
-
Call fanc1
|
32
26
|
|
27
|
+
Cells(9, 8).Value = Cells(9, 7).Value + d
|
28
|
+
Cells(13, 8).Value = Cells(13, 7).Value + d
|
29
|
+
Cells(14, 8).Value = Cells(14, 7).Value + d
|
30
|
+
Cells(15, 8).Value = Cells(15, 7).Value + d
|
31
|
+
|
32
|
+
Call fanc1
|
33
|
+
|
33
34
|
ElseIf Cells(9, 13) = "3" Then
|
34
35
|
|
35
|
-
|
36
|
+
p = Cells(Cells(9, 13).Value + 1, 2).Value
|
36
|
-
|
37
|
+
d = Cells(Cells(9, 15).Value + 1, 2).Value
|
37
38
|
|
38
|
-
|
39
|
+
Cells(10, 8).Value = Cells(10, 7).Value + d
|
39
|
-
|
40
|
+
Cells(13, 8).Value = Cells(13, 7).Value + d
|
40
|
-
|
41
|
+
Cells(16, 8).Value = Cells(16, 7).Value + d
|
41
|
-
|
42
|
+
Cells(17, 8).Value = Cells(17, 7).Value + d
|
42
|
-
|
43
|
+
|
43
|
-
|
44
|
+
Call fanc1
|
44
|
-
|
45
|
+
|
45
46
|
ElseIf Cells(9, 13) = "4" Then
|
46
47
|
|
47
|
-
|
48
|
+
p = Cells(Cells(9, 13).Value + 1, 2).Value
|
48
|
-
|
49
|
+
d = Cells(Cells(9, 15).Value + 1, 2).Value
|
49
50
|
|
50
|
-
|
51
|
+
Cells(11, 8).Value = Cells(11, 7).Value + d
|
51
|
-
|
52
|
+
Cells(14, 8).Value = Cells(14, 7).Value + d
|
52
|
-
|
53
|
+
Cells(16, 8).Value = Cells(16, 7).Value + d
|
53
|
-
|
54
|
+
Cells(18, 8).Value = Cells(18, 7).Value + d
|
54
|
-
|
55
|
-
Call fanc1
|
56
55
|
|
56
|
+
Call fanc1
|
57
|
+
|
57
58
|
ElseIf Cells(9, 13) = "5" Then
|
58
59
|
|
59
|
-
|
60
|
+
p = Cells(Cells(9, 13).Value + 1, 2).Value
|
60
|
-
|
61
|
+
d = Cells(Cells(9, 15).Value + 1, 2).Value
|
61
62
|
|
62
|
-
|
63
|
+
Cells(12, 8).Value = Cells(12, 7).Value + d
|
63
|
-
|
64
|
+
Cells(15, 8).Value = Cells(15, 7).Value + d
|
64
|
-
|
65
|
+
Cells(17, 8).Value = Cells(17, 7).Value + d
|
65
|
-
|
66
|
+
Cells(18, 8).Value = Cells(18, 7).Value + d
|
66
|
-
|
67
|
-
Call fanc1
|
68
67
|
|
68
|
+
Call fanc1
|
69
|
+
|
69
70
|
End If
|
70
71
|
|
71
72
|
End Sub
|
72
73
|
|
73
74
|
Function fanc1()
|
74
75
|
|
75
|
-
|
76
|
+
Dim p As Integer
|
76
|
-
|
77
|
+
p = Cells(Cells(9, 13).Value + 1, 2).Value
|
77
|
-
|
78
|
+
|
78
79
|
If Cells(9, 15) = "1" Then
|
79
80
|
|
80
|
-
|
81
|
+
Cells(9, 8).Value = Cells(9, 7).Value + p
|
81
|
-
|
82
|
+
Cells(10, 8).Value = Cells(10, 7).Value + p
|
82
|
-
|
83
|
+
Cells(11, 8).Value = Cells(11, 7).Value + p
|
83
|
-
|
84
|
+
Cells(12, 8).Value = Cells(12, 7).Value + p
|
84
85
|
|
85
86
|
ElseIf Cells(9, 15) = "2" Then
|
86
87
|
|
87
|
-
|
88
|
+
Cells(9, 8).Value = Cells(9, 7).Value + p
|
88
|
-
|
89
|
+
Cells(13, 8).Value = Cells(13, 7).Value + p
|
89
|
-
|
90
|
+
Cells(14, 8).Value = Cells(14, 7).Value + p
|
90
|
-
|
91
|
+
Cells(15, 8).Value = Cells(15, 7).Value + p
|
91
92
|
|
92
93
|
ElseIf Cells(9, 15) = "3" Then
|
93
94
|
|
94
|
-
|
95
|
+
Cells(10, 8).Value = Cells(10, 7).Value + p
|
95
|
-
|
96
|
+
Cells(13, 8).Value = Cells(13, 7).Value + p
|
96
|
-
|
97
|
+
Cells(16, 8).Value = Cells(16, 7).Value + p
|
97
|
-
|
98
|
+
Cells(17, 8).Value = Cells(17, 7).Value + p
|
98
99
|
|
99
|
-
|
100
100
|
ElseIf Cells(9, 15) = "4" Then
|
101
101
|
|
102
|
+
Cells(11, 8).Value = Cells(11, 7).Value + p
|
103
|
+
Cells(14, 8).Value = Cells(14, 7).Value + p
|
104
|
+
Cells(16, 8).Value = Cells(16, 7).Value + p
|
105
|
+
Cells(18, 8).Value = Cells(18, 7).Value + p
|
102
106
|
|
103
|
-
Cells(11, 8).Value = Cells(11, 7).Value + p
|
104
|
-
Cells(14, 8).Value = Cells(14, 7).Value + p
|
105
|
-
Cells(16, 8).Value = Cells(16, 7).Value + p
|
106
|
-
Cells(18, 8).Value = Cells(18, 7).Value + p
|
107
|
-
|
108
|
-
|
109
107
|
ElseIf Cells(9, 15) = "5" Then
|
110
108
|
|
111
|
-
|
109
|
+
Cells(12, 8).Value = Cells(12, 7).Value + p
|
112
|
-
|
110
|
+
Cells(15, 8).Value = Cells(15, 7).Value + p
|
113
|
-
|
111
|
+
Cells(17, 8).Value = Cells(17, 7).Value + p
|
114
|
-
|
112
|
+
Cells(18, 8).Value = Cells(18, 7).Value + p
|
115
113
|
|
116
114
|
End If
|
117
115
|
|
118
|
-
End Function
|
116
|
+
End Function
|
117
|
+
```
|