回答編集履歴

1

修正

2021/01/19 00:15

投稿

radames1000
radames1000

スコア1923

test CHANGED
@@ -1,5 +1,3 @@
1
- ざっくりですが。
2
-
3
1
  ```vba
4
2
 
5
3
  Option Explicit
@@ -12,9 +10,13 @@
12
10
 
13
11
  Dim myPath, buf As String
14
12
 
13
+ Dim myFile() As String
14
+
15
- Dim lngLeft As Long, lngTop As Long
15
+ Dim lngLeft As Long
16
16
 
17
17
  Dim i As Long, j As Long
18
+
19
+ Dim cnt() As Long
18
20
 
19
21
 
20
22
 
@@ -24,59 +26,13 @@
24
26
 
25
27
  buf = Dir(Path + "\target\" + "*.jpg")
26
28
 
27
-
28
-
29
- lngLeft = 296
30
-
31
- lngTop = 106.875
32
-
33
-
34
-
35
- i = 1
36
-
37
- j = 1
38
-
39
29
  Do While buf <> ""
40
30
 
41
- If i > 6 Then
31
+ j = j + 1
42
32
 
43
- i = 1
33
+ ReDim Preserve myFile(j)
44
34
 
45
- j = j + 1
46
-
47
- lngLeft = 296
35
+ myFile(j) = buf
48
-
49
- End If
50
-
51
- With Sheets("view").Pictures.Insert(myPath + "\target\" + buf)
52
-
53
-
54
-
55
- .Top = lngTop * j
56
-
57
- .Left = lngLeft
58
-
59
-
60
-
61
- .Width = 53
62
-
63
- .Height = 30
64
-
65
-
66
-
67
- lngLeft = lngLeft + 53 + 5
68
-
69
-
70
-
71
- Application.Wait [Now()] + 350 / 86400000
72
-
73
-
74
-
75
- End With
76
-
77
- i = i + 1
78
-
79
-
80
36
 
81
37
  buf = Dir()
82
38
 
@@ -84,8 +40,60 @@
84
40
 
85
41
 
86
42
 
43
+ ReDim cnt(6)
44
+
87
- End Sub
45
+ cnt(1) = 1
46
+
47
+ For i = 2 To 5
48
+
49
+ cnt(i) = Int(j * 0.2 * (i - 1))
50
+
51
+ Next
52
+
53
+ cnt(6) = j
88
54
 
89
55
 
90
56
 
57
+ lngLeft = 296
58
+
59
+ For i = 1 To 6
60
+
61
+ With Sheets("view").Pictures.Insert(myPath & "\target\" & myFile(cnt(i)))
62
+
63
+
64
+
65
+ .Top = 106.875
66
+
67
+ .Left = lngLeft
68
+
69
+
70
+
71
+ .Width = 53
72
+
73
+ .Height = 30
74
+
75
+
76
+
77
+ lngLeft = lngLeft + 53 + 5
78
+
79
+
80
+
81
+ Application.Wait [Now()] + 350 / 86400000
82
+
83
+
84
+
85
+ End With
86
+
87
+ Next
88
+
89
+
90
+
91
+ End Sub
92
+
91
93
  ```
94
+
95
+ 「いい感じ」「まんべんなく」「なんとなく」という表現では
96
+
97
+ 何がしたいかわかりません。
98
+
99
+ 相手に伝わるようにしてください。