回答編集履歴

2

修正

2019/02/14 06:19

投稿

papinianus
papinianus

スコア12705

test CHANGED
@@ -6,13 +6,9 @@
6
6
 
7
7
  Dim i As Long
8
8
 
9
- Dim j As Long
10
-
11
9
  Dim strArryHoge() As Variant
12
10
 
13
11
 
14
-
15
- j = 1
16
12
 
17
13
  For i = 5 To Worksheets("シート1").Cells(Rows.Count, "B").End(xlUp).Row
18
14
 
@@ -20,15 +16,13 @@
20
16
 
21
17
  ' 配列を再定義する
22
18
 
23
- ReDim Preserve strArryHoge(j)
19
+ ReDim Preserve strArryHoge(i - 4)
24
20
 
25
21
 
26
22
 
27
23
  ' 配列に値を格納する
28
24
 
29
- strArryHoge(j) = Worksheets("シート1").Cells(i, "B").Row
25
+ strArryHoge(i - 5) = Worksheets("シート1").Cells(i, "B").Row
30
-
31
- j = j + 1
32
26
 
33
27
  Next
34
28
 

1

修正

2019/02/14 06:19

投稿

papinianus
papinianus

スコア12705

test CHANGED
@@ -1,5 +1,39 @@
1
1
  ```vba
2
2
 
3
+ Sub test()
4
+
5
+
6
+
3
- For i = 5 To
7
+ Dim i As Long
8
+
9
+ Dim j As Long
10
+
11
+ Dim strArryHoge() As Variant
12
+
13
+
14
+
15
+ j = 1
16
+
17
+ For i = 5 To Worksheets("シート1").Cells(Rows.Count, "B").End(xlUp).Row
18
+
19
+
20
+
21
+ ' 配列を再定義する
22
+
23
+ ReDim Preserve strArryHoge(j)
24
+
25
+
26
+
27
+ ' 配列に値を格納する
28
+
29
+ strArryHoge(j) = Worksheets("シート1").Cells(i, "B").Row
30
+
31
+ j = j + 1
32
+
33
+ Next
34
+
35
+
36
+
37
+ End Sub
4
38
 
5
39
  ```