質問編集履歴

3

補足

2020/12/06 02:47

投稿

Cabriolet
Cabriolet

スコア3

test CHANGED
File without changes
test CHANGED
@@ -46,6 +46,42 @@
46
46
 
47
47
 
48
48
 
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+ ![イメージ説明](4d7863ea23ef4dd17dfc321682b875d1.png)
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
49
85
  ### 発生している問題・エラーメッセージ
50
86
 
51
87
  格納した配列からの一括入力時にエラー

2

文法の修正

2020/12/06 02:47

投稿

Cabriolet
Cabriolet

スコア3

test CHANGED
File without changes
test CHANGED
@@ -34,9 +34,11 @@
34
34
 
35
35
 
36
36
 
37
-
37
+ ### 補足
38
+
38
-
39
+ ・配列からの一括入力時、途中までは正しく入力されます。
40
+
39
-
41
+ ・エラーで止まった検索値は、検索範囲に含まれている値です。
40
42
 
41
43
 
42
44
 

1

文法の修正

2020/12/06 02:41

投稿

Cabriolet
Cabriolet

スコア3

test CHANGED
File without changes
test CHANGED
@@ -84,22 +84,46 @@
84
84
 
85
85
 
86
86
 
87
+ d = Application.GetOpenFilename(",*.xlsx")
88
+
89
+ d = Mid(d, InStrRev(d, "\") + 1)
90
+
91
+
92
+
93
+ If b <> "False" Then
94
+
95
+
96
+
97
+ Workbooks.Open d
98
+
99
+ Set e = Workbooks(d).Worksheets("Sheet1")
100
+
101
+
102
+
103
+ Else
104
+
105
+
106
+
107
+ MsgBox "キャンセルしました"
108
+
109
+
110
+
111
+ End If
112
+
113
+
114
+
115
+
116
+
87
- b = Application.GetOpenFilename(",*.XLSX")
117
+ b = Application.GetOpenFilename(",*.XLSX")
88
-
118
+
89
- b = Mid(b, InStrRev(b, "\") + 1)
119
+ b = Mid(b, InStrRev(b, "\") + 1)
90
-
91
- d = Application.GetOpenFilename(",*.XLSX")
92
-
93
- d = Mid(b, InStrRev(b, "\") + 1)
94
-
95
-
96
-
97
-
98
-
99
- If b <> "False" Then
100
120
 
101
121
 
102
122
 
123
+ If b <> "False" Then
124
+
125
+
126
+
103
127
  Workbooks.Open b
104
128
 
105
129
  Set c = Workbooks(b).Worksheets("Sheet1")
@@ -118,90 +142,74 @@
118
142
 
119
143
 
120
144
 
145
+
146
+
147
+ Set dir = New Dictionary
148
+
149
+
150
+
151
+ isaigo = e.Cells(Rows.Count, 3).End(xlUp).row
152
+
153
+ hsaisho = c.Cells(Rows.Count, 43).End(xlUp).row + 1
154
+
155
+ hsaigo = c.Cells(Rows.Count, 8).End(xlUp).row
156
+
157
+
158
+
159
+ MsgBox isaigo
160
+
161
+ MsgBox hsaigo
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ For name_c = 4 To isaigo
170
+
171
+
172
+
173
+
174
+
121
- If b <> "False" Then
175
+ If dir.Exists(e.Cells(name_c, 3).Value) = False Then
122
-
123
-
124
-
125
- Workbooks.Open d
176
+
126
-
127
- Set e = Workbooks(d).Worksheets("Sheet1")
177
+ dir.Add Key:=e.Cells(name_c, 3).Value, Item:=e.Cells(name_c, 6).Value
128
-
129
-
130
-
131
- Else
178
+
132
-
133
-
134
-
135
- MsgBox "キャンセルしました"
136
-
137
-
138
-
139
- End If
179
+ End If
180
+
140
-
181
+ Next name_c
182
+
183
+
184
+
185
+
186
+
187
+
188
+
141
-
189
+ '▼セル参照回数を減らす為に配列へ格納
190
+
142
-
191
+ buff = c.Range(c.Cells(1, 1), c.Cells(hsaigo, 43))
192
+
193
+
194
+
195
+
196
+
143
-
197
+ For name_b = hsaisho To hsaigo
198
+
199
+
200
+
201
+ buff(name_b, 43) = dir.Item(CStr(buff(name_b, 10)))
202
+
203
+
204
+
205
+ Next name_b
206
+
207
+
208
+
209
+
210
+
211
+ '▼配列からまとめて入力
144
212
 
145
213
 
146
214
 
147
-
148
-
149
- Set dir = New Dictionary
150
-
151
-
152
-
153
- isaigo = e.Cells(Rows.Count, 3).End(xlUp).row
154
-
155
- hsaisho = c.Cells(Rows.Count, 43).End(xlUp).row + 1
156
-
157
- hsaigo = c.Cells(Rows.Count, 8).End(xlUp).row
158
-
159
-
160
-
161
- For name_c = 4 To isaigo
162
-
163
-
164
-
165
-
166
-
167
- If dir.Exists(e.Cells(name_c, 3).Value) = False Then
168
-
169
- dir.Add Key:=e.Cells(name_c, 3).Value, Item:=e.Cells(name_c, 6).Value
170
-
171
- End If
172
-
173
- Next name_c
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
- '▼セル参照回数を減らす為に配列へ格納
182
-
183
- buff = c.Range(c.Cells(1, 1), c.Cells(hsaigo, 43))
184
-
185
-
186
-
187
-
188
-
189
- For name_b = hsaisho To hsaigo
190
-
191
-
192
-
193
- buff(name_b, 43) = dir.Item(CStr(buff(name_b, 10)))
194
-
195
-
196
-
197
- Next name_b
198
-
199
-
200
-
201
-
202
-
203
- '▼配列からまとめて入力 ※ここでエラー発生!
204
-
205
-
206
-
207
215
  c.Range(c.Cells(1, 1), c.Cells(hsaigo, 43)) = buff