回答編集履歴
1
工数処理を別のサブルーチンへもっていく処理を追記
test
CHANGED
@@ -21,3 +21,157 @@
|
|
21
21
|
If Cells(n, 3) = "" Then
|
22
22
|
|
23
23
|
```
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
**追記**
|
28
|
+
|
29
|
+
工数の処理部分を別のサブルーチンに持って行ったほうが良さそうです。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
```VBA
|
34
|
+
|
35
|
+
'担当者が空白の時スキップする
|
36
|
+
|
37
|
+
If Cells(n, 3) = " " Then
|
38
|
+
|
39
|
+
n = n + 1
|
40
|
+
|
41
|
+
End If
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
'工数
|
46
|
+
|
47
|
+
'ここから・・・
|
48
|
+
|
49
|
+
wsSet.Cells(lngRowsNo, 4).Value = .Cells(n, 5).Value
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
wsSet.Cells(lngRowsNo, 5).Value = .Cells(n, 8).Value
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
wsSet.Cells(lngRowsNo, 6).Value = .Cells(n, 11).Value
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
wsSet.Cells(lngRowsNo, 7).Value = .Cells(n, 14).Value
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
wsSet.Cells(lngRowsNo, 8).Value = .Cells(n, 17).Value
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
wsSet.Cells(lngRowsNo, 9).Value = .Cells(n, 20).Value
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
wsSet.Cells(lngRowsNo, 10).Value = .Cells(n, 23).Value
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
wsSet.Cells(lngRowsNo, 11).Value = .Cells(n, 26).Value
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
wsSet.Cells(lngRowsNo, 12).Value = .Cells(n, 29).Value
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
wsSet.Cells(lngRowsNo, 13).Value = .Cells(n, 32).Value
|
86
|
+
|
87
|
+
'ここまでを別のサブルーチンに持ってく。
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
'1行下へ
|
92
|
+
|
93
|
+
lngRowsNo = lngRowsNo + 1
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
Next n
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
以下を試してみてください。
|
104
|
+
|
105
|
+
```VBA
|
106
|
+
|
107
|
+
'担当者が空白でなければ、工数処理を呼ぶ。
|
108
|
+
|
109
|
+
If Cells(n, 3) <> "" Then
|
110
|
+
|
111
|
+
Call 工数処理(wsSet, lngRowsNo, n)
|
112
|
+
|
113
|
+
End If
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
'1行下へ
|
118
|
+
|
119
|
+
lngRowsNo = lngRowsNo + 1
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
Next n
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
End Sub
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
'例えば、「工数処理」という名前でサブルーチンを作成する。
|
132
|
+
|
133
|
+
Sub 工数処理(wsSet As Worksheet, lngRowsNo As Long, n As Long)
|
134
|
+
|
135
|
+
wsSet.Cells(lngRowsNo, 4).Value = .Cells(n, 5).Value
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
wsSet.Cells(lngRowsNo, 5).Value = .Cells(n, 8).Value
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
wsSet.Cells(lngRowsNo, 6).Value = .Cells(n, 11).Value
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
wsSet.Cells(lngRowsNo, 7).Value = .Cells(n, 14).Value
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
wsSet.Cells(lngRowsNo, 8).Value = .Cells(n, 17).Value
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
wsSet.Cells(lngRowsNo, 9).Value = .Cells(n, 20).Value
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
wsSet.Cells(lngRowsNo, 10).Value = .Cells(n, 23).Value
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
wsSet.Cells(lngRowsNo, 11).Value = .Cells(n, 26).Value
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
wsSet.Cells(lngRowsNo, 12).Value = .Cells(n, 29).Value
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
wsSet.Cells(lngRowsNo, 13).Value = .Cells(n, 32).Value
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
End Sub
|
176
|
+
|
177
|
+
```
|