回答編集履歴
2
追記
test
CHANGED
@@ -127,3 +127,113 @@
|
|
127
127
|
|
128
128
|
|
129
129
|
```
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
---
|
134
|
+
|
135
|
+
<追記>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
```VBA
|
140
|
+
|
141
|
+
Private Function PutDataEx2(ws As Worksheet, Dat As Variant, EvaluationSheetName As Variant) As Boolean
|
142
|
+
|
143
|
+
Dim TargetRo As Long
|
144
|
+
|
145
|
+
Dim Col As Integer, strDat As String
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
TargetRo = getLastRoExTempRow(ws) + 1
|
150
|
+
|
151
|
+
If TargetRo < 9 Then TargetRo = 9
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
Call CopyTemplateRow(ws, TargetRo)
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
Dim arr(1 To 44) '格納用配列
|
160
|
+
|
161
|
+
For Col = 1 To 44
|
162
|
+
|
163
|
+
Select Case Col
|
164
|
+
|
165
|
+
Case 1
|
166
|
+
|
167
|
+
If Dat(14) = "継続" Then
|
168
|
+
|
169
|
+
strDat = "2"
|
170
|
+
|
171
|
+
ElseIf Dat(14) = "新規" Then
|
172
|
+
|
173
|
+
strDat = "1"
|
174
|
+
|
175
|
+
Else
|
176
|
+
|
177
|
+
strDat = ""
|
178
|
+
|
179
|
+
End If
|
180
|
+
|
181
|
+
arr(Col) = strDat
|
182
|
+
|
183
|
+
Case 2
|
184
|
+
|
185
|
+
If Dat(15) = "外注" Then
|
186
|
+
|
187
|
+
strDat = "2"
|
188
|
+
|
189
|
+
ElseIf Dat(15) = "資材" Then
|
190
|
+
|
191
|
+
strDat = "1"
|
192
|
+
|
193
|
+
Else
|
194
|
+
|
195
|
+
strDat = ""
|
196
|
+
|
197
|
+
End If
|
198
|
+
|
199
|
+
arr(Col) = strDat
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
Case 44 '前一年間の取引実績
|
206
|
+
|
207
|
+
arr(Col) = Dat(Col - 4)
|
208
|
+
|
209
|
+
Case Else
|
210
|
+
|
211
|
+
arr(Col) = Dat(Col - 3) 'Dat(Col - 5)
|
212
|
+
|
213
|
+
End Select
|
214
|
+
|
215
|
+
Next
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
'格納
|
220
|
+
|
221
|
+
With ws.Rows(TargetRo).Resize(, 44)
|
222
|
+
|
223
|
+
.Value = arr
|
224
|
+
|
225
|
+
'.Font.Name = "Meiryo UI"
|
226
|
+
|
227
|
+
End With
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
PutDataEx2 = True
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
End Function
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
```
|
1
追記
test
CHANGED
@@ -43,3 +43,87 @@
|
|
43
43
|
|
44
44
|
|
45
45
|
```
|
46
|
+
|
47
|
+
---
|
48
|
+
|
49
|
+
<追記>
|
50
|
+
|
51
|
+
転記元は1ファイルに100シート程度、転記先は1シートに100行程度、という情報から、
|
52
|
+
|
53
|
+
転記先の1行と転記元の1シートが対応づいていると仮定すると、
|
54
|
+
|
55
|
+
後続の処理は以下の感じにすればいいのかな、という想像をしています。
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
```VBA
|
60
|
+
|
61
|
+
'転記先シート
|
62
|
+
|
63
|
+
Dim EvaluationSheet As Worksheet
|
64
|
+
|
65
|
+
Set EvaluationSheet = ThisWorkbook.Worksheets(1)
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
With EvaluationSheet
|
70
|
+
|
71
|
+
Dim startRow, endRow
|
72
|
+
|
73
|
+
startRow = 10 ’たとえば10行目からがデータ行の場合
|
74
|
+
|
75
|
+
endRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
'転記先データ範囲
|
80
|
+
|
81
|
+
Dim EvaRange As Range, EvaArr As Variant
|
82
|
+
|
83
|
+
Set EvaRange = .Range("A1").Resize(endRow, 44)
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
'転記先の値を転記先用配列に取得
|
88
|
+
|
89
|
+
EvaArr = EvaArr.Value
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
'順次処理
|
94
|
+
|
95
|
+
Dim TargetRo, shtName
|
96
|
+
|
97
|
+
For TargetRo = startRow To endRow
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
'転記元シート名の決定
|
102
|
+
|
103
|
+
shtName = EvaArr(TargetRo, 1)
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
'シート名をキーに連想配列から配列を取り出し、転記先用配列の各列の値をセット
|
108
|
+
|
109
|
+
EvaArr(TargetRo, 4) = dic(shtName)(2, 13) '
|
110
|
+
|
111
|
+
EvaArr(TargetRo, 5) = dic(shtName)(12, 11) '業種
|
112
|
+
|
113
|
+
'
|
114
|
+
|
115
|
+
EvaArr(TargetRo, 44) = dic(shtName)(33, 22) 'xx
|
116
|
+
|
117
|
+
Next
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
'転記先用配列の値をシートに反映
|
122
|
+
|
123
|
+
.Value = EvaArr
|
124
|
+
|
125
|
+
End With
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
```
|