回答編集履歴

2

teisei

2020/08/27 17:03

投稿

sinzou
sinzou

スコア392

test CHANGED
@@ -94,11 +94,11 @@
94
94
 
95
95
  With .Chart.FullSeriesCollection(j)
96
96
 
97
- .Name = "系統" & j + 1
97
+ .Name = "系統" & j
98
98
 
99
99
  .Trendlines.Add Type:=xlLinear, Forward:=0, Backward:=0, _
100
100
 
101
- DisplayEquation:=0, DisplayRSquared:=0, Name:="線形 (系統" & j + 1 & ")"
101
+ DisplayEquation:=0, DisplayRSquared:=0, Name:="線形 (系統" & j & ")"
102
102
 
103
103
 
104
104
 

1

修正

2020/08/27 17:03

投稿

sinzou
sinzou

スコア392

test CHANGED
@@ -1,58 +1,262 @@
1
+ (修正、載せ替え)
2
+
1
- ![に適用すると](31cbbe6df7d07bae01792b28af46e34a.png)
3
+ ![イメージ説明](05782742e06dd55188b9c413636986b6.png)
2
-
3
- に適用すると
4
+
4
-
5
- ![に適用すると](16c0ef7cf59a8ad850231f872ce50fa7.png)
6
-
7
- に加工できる、あと色と濃度かえるとか、、、ちがった??
8
-
9
-
10
-
11
- ```vba
5
+ ```VBA
12
-
6
+
13
- Sub tes0()
7
+ Sub tes01()
14
-
15
- '
8
+
16
-
9
+
10
+
17
- Dim j, linCount, newLin, mkStyle
11
+ Dim shName(2) As String, shpName
12
+
18
-
13
+ Dim j, col, AreaWidth, AreaHeight
14
+
19
-
15
+ Dim PlotAreaTop, PlotAreaLeft, PlotAreaWidth, PlotAreaHeight
20
-
16
+
17
+
18
+
21
- With ActiveChart
19
+ With ActiveSheet.Shapes.AddChart.Chart
20
+
22
-
21
+ '.ChartType = xlXYScatter '分布図
22
+
23
+ .ChartType = xlLine '折れ線
24
+
25
+
26
+
27
+ .SeriesCollection.NewSeries
28
+
23
- linCount = .FullSeriesCollection.Count 'グラフのデータ系列の数
29
+ With .FullSeriesCollection(1)
24
-
30
+
25
- For j = 1 To linCount
31
+ .Name = "=Sheet2!$B$1"
32
+
26
-
33
+ .XValues = "=Sheet2!$A$2:$A$16"
34
+
35
+ .Values = "=Sheet2!$B$2:$B$16"
36
+
37
+ .MarkerStyle = 8
38
+
39
+ .MarkerSize = 5
40
+
27
- newLin = j + linCount
41
+ .MarkerBackgroundColorIndex = 2
42
+
43
+
44
+
45
+ End With
46
+
47
+
28
48
 
29
49
  .SeriesCollection.NewSeries
30
50
 
31
- .FullSeriesCollection(newLin).Values = .FullSeriesCollection(j).Values
32
-
33
-
34
-
35
- '元系統をマーカーに
36
-
37
- With .FullSeriesCollection(j)
38
-
39
- .Format.Line.Visible = msoFalse
40
-
41
- '.MarkerSize = 5
42
-
43
- End With
44
-
45
- 'コピーした系統をラインに
46
-
47
- With .FullSeriesCollection(newLin)
48
-
49
- .MarkerStyle = -4142
51
+ With .FullSeriesCollection(2)
52
+
53
+ .Name = "=Sheet2!$D$1"
54
+
55
+ .XValues = "=Sheet2!$A$2:$A$16"
56
+
57
+ .Values = "=Sheet2!$D$2:$D$16"
58
+
59
+ .MarkerStyle = 8
60
+
61
+ .MarkerSize = 5
62
+
63
+ .MarkerBackgroundColorIndex = 2
64
+
65
+ End With
66
+
67
+ .HasLegend = False
68
+
69
+ End With
70
+
71
+ shName(0) = ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name
72
+
73
+
74
+
75
+ 'グラフの複写
76
+
77
+ shName(0) = ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name
78
+
79
+ ActiveSheet.Shapes(shName(0)).Copy
80
+
81
+ Range("F38").Select
82
+
83
+ ActiveSheet.Paste
84
+
85
+ shName(2) = ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name
86
+
87
+
88
+
89
+ '系統文字列変更、追加
90
+
91
+ With ActiveSheet.Shapes(shName(0))
92
+
93
+ For j = 1 To .Chart.FullSeriesCollection.Count
94
+
95
+ With .Chart.FullSeriesCollection(j)
96
+
97
+ .Name = "系統" & j + 1
98
+
99
+ .Trendlines.Add Type:=xlLinear, Forward:=0, Backward:=0, _
100
+
101
+ DisplayEquation:=0, DisplayRSquared:=0, Name:="線形 (系統" & j + 1 & ")"
102
+
103
+
104
+
105
+ col = .Format.Line.ForeColor
106
+
107
+ With .Trendlines(1)
108
+
109
+ With .Format.Line
110
+
111
+ .Visible = msoTrue
112
+
113
+ .ForeColor.RGB = col
114
+
115
+ .DashStyle = msoLineSysDash
116
+
117
+ .Transparency = 0.4
118
+
119
+ End With
120
+
121
+
122
+
123
+ End With
124
+
125
+ With .Trendlines(1)
126
+
127
+ .DisplayEquation = True
128
+
129
+ .DisplayRSquared = True
130
+
131
+ End With
132
+
133
+ End With
134
+
135
+ Next
136
+
137
+ .Top = Range("F5").Top
138
+
139
+ .Left = Range("F5").Left
140
+
141
+ .Height = 300
142
+
143
+ .Width = 400
144
+
145
+ End With
146
+
147
+ 'グラフの複写
148
+
149
+ ActiveSheet.Shapes(shName(0)).Copy
150
+
151
+ Range("F20").Select
152
+
153
+ ActiveSheet.Paste
154
+
155
+ shName(1) = ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name
156
+
157
+
158
+
159
+
160
+
161
+ 'shName(0)
162
+
163
+ With ActiveSheet.Shapes(shName(0)).Chart
164
+
165
+ .HasLegend = True
166
+
167
+ For j = 1 To .FullSeriesCollection.Count
168
+
169
+
170
+
171
+ With .FullSeriesCollection(j)
172
+
173
+ With .Format.Line
174
+
175
+ col = .ForeColor
176
+
177
+ .ForeColor.RGB = msoThemeColorBackground1
178
+
179
+ .Transparency = 1
180
+
181
+ End With
182
+
183
+ '.MarkerBackgroundColor = msoThemeColorBackground1
184
+
185
+ .MarkerForegroundColor = col
186
+
187
+ End With
188
+
189
+ Next
190
+
191
+ End With
192
+
193
+
194
+
195
+ 'shName(1)
196
+
197
+ With ActiveSheet.Shapes(shName(1)).Chart
198
+
199
+ For j = 1 To .FullSeriesCollection.Count
200
+
201
+ With .FullSeriesCollection(j)
202
+
203
+ .Format.Line.ForeColor.RGB = RGB(255, 255, 255)
204
+
205
+ .MarkerBackgroundColor = RGB(255, 255, 255)
206
+
207
+ .MarkerForegroundColor = RGB(255, 255, 255)
208
+
209
+ End With
210
+
211
+ Next
212
+
213
+ With .ChartArea
214
+
215
+ .Fill.Visible = msoFalse
216
+
217
+ .Format.Line.Visible = msoFalse
218
+
219
+ End With
220
+
221
+ With .PlotArea
222
+
223
+ .Format.Fill.Visible = msoTrue
224
+
225
+ .Format.Line.Visible = msoFalse
226
+
227
+ End With
228
+
229
+ With .Axes(xlValue)
50
230
 
51
231
  With .Format.Line
52
232
 
53
233
  .Visible = msoTrue
54
234
 
235
+ .ForeColor.ObjectThemeColor = msoThemeColorBackground1
236
+
237
+ .ForeColor.TintAndShade = 0
238
+
239
+ .ForeColor.Brightness = 0
240
+
241
+ .Transparency = 1
242
+
243
+ End With
244
+
245
+ End With
246
+
247
+ With .Axes(xlCategory)
248
+
249
+ With .Format.Line
250
+
55
- .DashStyle = msoLineSysDot
251
+ .Visible = msoTrue
252
+
253
+ .ForeColor.ObjectThemeColor = msoThemeColorBackground1
254
+
255
+ .ForeColor.TintAndShade = 0
256
+
257
+ .ForeColor.Brightness = 0
258
+
259
+ .Transparency = 1
56
260
 
57
261
  End With
58
262
 
@@ -60,18 +264,168 @@
60
264
 
61
265
 
62
266
 
63
- .FullSeriesCollection(j).Name = "系統" & j
267
+
64
-
65
- .FullSeriesCollection(newLin).Name = "線形(系統" & j & ")"
268
+
66
-
67
- Next j
68
-
69
- '.FullSeriesCollection(j).Format.Fill.ForeColor.ObjectThemeColor = msoThemeColorBackground1
70
-
71
- End With
269
+ End With
270
+
271
+
272
+
273
+
274
+
275
+ 'shName(2)の加工
276
+
277
+ With ActiveSheet.Shapes(shName(2)).Chart
278
+
279
+ For j = 1 To .FullSeriesCollection.Count
280
+
281
+ With .FullSeriesCollection(j)
282
+
283
+ With .Format.Line
284
+
285
+ col = .ForeColor
286
+
287
+ .ForeColor.RGB = msoThemeColorBackground1
288
+
289
+ .Transparency = 1
290
+
291
+ End With
292
+
293
+ '.MarkerBackgroundColor = msoThemeColorBackground1
294
+
295
+ .MarkerForegroundColor = col
296
+
297
+ End With
298
+
299
+ Next
300
+
301
+ With .ChartArea
302
+
303
+ .Fill.Visible = msoFalse
304
+
305
+ .Format.Line.Visible = msoFalse
306
+
307
+ End With
308
+
309
+ With .PlotArea
310
+
311
+ .Format.Fill.Visible = msoFalse
312
+
313
+ .Format.Line.Visible = msoFalse
314
+
315
+ End With
316
+
317
+ With .Axes(xlCategory)
318
+
319
+ .Format.Fill.Visible = msoFalse
320
+
321
+ .Format.Line.Visible = msoFalse
322
+
323
+ .HasMajorGridlines = False
324
+
325
+ .HasMinorGridlines = False
326
+
327
+ .HasTitle = False
328
+
329
+ End With
330
+
331
+
332
+
333
+ With .Axes(xlValue)
334
+
335
+ .Format.Fill.Visible = msoFalse
336
+
337
+ .Format.Line.Visible = msoFalse
338
+
339
+ .HasMajorGridlines = False
340
+
341
+ .HasMinorGridlines = False
342
+
343
+ .HasTitle = False
344
+
345
+ End With
346
+
347
+ End With
348
+
349
+
350
+
351
+
352
+
353
+ 'グラフエリアをそろえる
354
+
355
+ With ActiveSheet.Shapes(shName(0))
356
+
357
+ AreaWidth = .Width
358
+
359
+ AreaHeight = .Height
360
+
361
+
362
+
363
+ PlotAreaTop = .Chart.PlotArea.Top + 10
364
+
365
+ PlotAreaLeft = .Chart.PlotArea.Left + 10
366
+
367
+ PlotAreaWidth = .Chart.PlotArea.Width
368
+
369
+ PlotAreaHeight = .Chart.PlotArea.Height
370
+
371
+ End With
372
+
373
+ 'プロットエリアをそろえる
374
+
375
+ For Each shpName In shName()
376
+
377
+ With ActiveSheet.Shapes(shpName)
378
+
379
+ .Width = AreaWidth
380
+
381
+ .Height = AreaHeight
382
+
383
+ End With
384
+
385
+ With ActiveSheet.Shapes(shpName).Chart
386
+
387
+ .PlotArea.Top = PlotAreaTop
388
+
389
+ .PlotArea.Left = PlotAreaLeft
390
+
391
+ .PlotArea.Width = PlotAreaWidth
392
+
393
+ .PlotArea.Height = PlotAreaHeight
394
+
395
+ End With
396
+
397
+ Next
398
+
399
+
400
+
401
+
402
+
403
+ '重ね合わせ
404
+
405
+ With ActiveSheet.Shapes(shName(1))
406
+
407
+ .Top = Range("F5").Top '位置を設定
408
+
409
+ .Left = Range("F5").Left
410
+
411
+ .ZOrder msoBringForward
412
+
413
+ End With
414
+
415
+ With ActiveSheet.Shapes(shName(2))
416
+
417
+ .Top = Range("F5").Top '位置を設定
418
+
419
+ .Left = Range("F5").Left
420
+
421
+ .ZOrder msoBringForward
422
+
423
+ End With
72
424
 
73
425
 
74
426
 
75
427
  End Sub
76
428
 
429
+
430
+
77
431
  ```