回答編集履歴
2
teisei
answer
CHANGED
@@ -46,9 +46,9 @@
|
|
46
46
|
With ActiveSheet.Shapes(shName(0))
|
47
47
|
For j = 1 To .Chart.FullSeriesCollection.Count
|
48
48
|
With .Chart.FullSeriesCollection(j)
|
49
|
-
.Name = "系統" & j
|
49
|
+
.Name = "系統" & j
|
50
50
|
.Trendlines.Add Type:=xlLinear, Forward:=0, Backward:=0, _
|
51
|
-
DisplayEquation:=0, DisplayRSquared:=0, Name:="線形 (系統" & j
|
51
|
+
DisplayEquation:=0, DisplayRSquared:=0, Name:="線形 (系統" & j & ")"
|
52
52
|
|
53
53
|
col = .Format.Line.ForeColor
|
54
54
|
With .Trendlines(1)
|
1
修正
answer
CHANGED
@@ -1,39 +1,216 @@
|
|
1
|
+
(修正、載せ替え)
|
1
|
-

|
2
|
-
|
3
|
+
```VBA
|
3
|
-

|
4
|
-
|
4
|
+
Sub tes01()
|
5
5
|
|
6
|
-
```vba
|
7
|
-
Sub tes0()
|
8
|
-
'
|
9
|
-
Dim
|
6
|
+
Dim shName(2) As String, shpName
|
7
|
+
Dim j, col, AreaWidth, AreaHeight
|
8
|
+
Dim PlotAreaTop, PlotAreaLeft, PlotAreaWidth, PlotAreaHeight
|
9
|
+
|
10
|
+
With ActiveSheet.Shapes.AddChart.Chart
|
11
|
+
'.ChartType = xlXYScatter '分布図
|
12
|
+
.ChartType = xlLine '折れ線
|
13
|
+
|
14
|
+
.SeriesCollection.NewSeries
|
15
|
+
With .FullSeriesCollection(1)
|
16
|
+
.Name = "=Sheet2!$B$1"
|
17
|
+
.XValues = "=Sheet2!$A$2:$A$16"
|
18
|
+
.Values = "=Sheet2!$B$2:$B$16"
|
19
|
+
.MarkerStyle = 8
|
20
|
+
.MarkerSize = 5
|
21
|
+
.MarkerBackgroundColorIndex = 2
|
22
|
+
|
23
|
+
End With
|
10
24
|
|
11
|
-
With ActiveChart
|
12
|
-
linCount = .FullSeriesCollection.Count 'グラフのデータ系列の数
|
13
|
-
For j = 1 To linCount
|
14
|
-
newLin = j + linCount
|
15
25
|
.SeriesCollection.NewSeries
|
26
|
+
With .FullSeriesCollection(2)
|
27
|
+
.Name = "=Sheet2!$D$1"
|
28
|
+
.XValues = "=Sheet2!$A$2:$A$16"
|
29
|
+
.Values = "=Sheet2!$D$2:$D$16"
|
30
|
+
.MarkerStyle = 8
|
31
|
+
.MarkerSize = 5
|
32
|
+
.MarkerBackgroundColorIndex = 2
|
33
|
+
End With
|
34
|
+
.HasLegend = False
|
35
|
+
End With
|
16
|
-
|
36
|
+
shName(0) = ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name
|
37
|
+
|
17
|
-
|
38
|
+
'グラフの複写
|
39
|
+
shName(0) = ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name
|
40
|
+
ActiveSheet.Shapes(shName(0)).Copy
|
41
|
+
Range("F38").Select
|
42
|
+
ActiveSheet.Paste
|
43
|
+
shName(2) = ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name
|
44
|
+
|
18
|
-
'
|
45
|
+
'系統文字列変更、追加
|
46
|
+
With ActiveSheet.Shapes(shName(0))
|
47
|
+
For j = 1 To .Chart.FullSeriesCollection.Count
|
48
|
+
With .Chart.FullSeriesCollection(j)
|
49
|
+
.Name = "系統" & j + 1
|
50
|
+
.Trendlines.Add Type:=xlLinear, Forward:=0, Backward:=0, _
|
51
|
+
DisplayEquation:=0, DisplayRSquared:=0, Name:="線形 (系統" & j + 1 & ")"
|
52
|
+
|
53
|
+
col = .Format.Line.ForeColor
|
54
|
+
With .Trendlines(1)
|
55
|
+
With .Format.Line
|
56
|
+
.Visible = msoTrue
|
57
|
+
.ForeColor.RGB = col
|
58
|
+
.DashStyle = msoLineSysDash
|
59
|
+
.Transparency = 0.4
|
60
|
+
End With
|
61
|
+
|
62
|
+
End With
|
63
|
+
With .Trendlines(1)
|
64
|
+
.DisplayEquation = True
|
65
|
+
.DisplayRSquared = True
|
66
|
+
End With
|
67
|
+
End With
|
68
|
+
Next
|
69
|
+
.Top = Range("F5").Top
|
70
|
+
.Left = Range("F5").Left
|
71
|
+
.Height = 300
|
72
|
+
.Width = 400
|
73
|
+
End With
|
74
|
+
'グラフの複写
|
75
|
+
ActiveSheet.Shapes(shName(0)).Copy
|
76
|
+
Range("F20").Select
|
77
|
+
ActiveSheet.Paste
|
78
|
+
shName(1) = ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name
|
79
|
+
|
80
|
+
|
81
|
+
'shName(0)
|
82
|
+
With ActiveSheet.Shapes(shName(0)).Chart
|
83
|
+
.HasLegend = True
|
84
|
+
For j = 1 To .FullSeriesCollection.Count
|
85
|
+
|
19
|
-
|
86
|
+
With .FullSeriesCollection(j)
|
87
|
+
With .Format.Line
|
88
|
+
col = .ForeColor
|
89
|
+
.ForeColor.RGB = msoThemeColorBackground1
|
90
|
+
.Transparency = 1
|
91
|
+
End With
|
92
|
+
'.MarkerBackgroundColor = msoThemeColorBackground1
|
93
|
+
.MarkerForegroundColor = col
|
94
|
+
End With
|
95
|
+
Next
|
96
|
+
End With
|
97
|
+
|
98
|
+
'shName(1)
|
99
|
+
With ActiveSheet.Shapes(shName(1)).Chart
|
100
|
+
For j = 1 To .FullSeriesCollection.Count
|
101
|
+
With .FullSeriesCollection(j)
|
102
|
+
.Format.Line.ForeColor.RGB = RGB(255, 255, 255)
|
103
|
+
.MarkerBackgroundColor = RGB(255, 255, 255)
|
104
|
+
.MarkerForegroundColor = RGB(255, 255, 255)
|
105
|
+
End With
|
106
|
+
Next
|
107
|
+
With .ChartArea
|
108
|
+
.Fill.Visible = msoFalse
|
20
109
|
.Format.Line.Visible = msoFalse
|
21
|
-
'.MarkerSize = 5
|
22
110
|
End With
|
23
|
-
|
111
|
+
With .PlotArea
|
112
|
+
.Format.Fill.Visible = msoTrue
|
113
|
+
.Format.Line.Visible = msoFalse
|
114
|
+
End With
|
24
|
-
With .
|
115
|
+
With .Axes(xlValue)
|
25
|
-
.MarkerStyle = -4142
|
26
116
|
With .Format.Line
|
27
117
|
.Visible = msoTrue
|
118
|
+
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
|
119
|
+
.ForeColor.TintAndShade = 0
|
28
|
-
.
|
120
|
+
.ForeColor.Brightness = 0
|
121
|
+
.Transparency = 1
|
29
122
|
End With
|
30
123
|
End With
|
124
|
+
With .Axes(xlCategory)
|
125
|
+
With .Format.Line
|
126
|
+
.Visible = msoTrue
|
127
|
+
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
|
128
|
+
.ForeColor.TintAndShade = 0
|
129
|
+
.ForeColor.Brightness = 0
|
130
|
+
.Transparency = 1
|
131
|
+
End With
|
132
|
+
End With
|
31
133
|
|
32
|
-
|
134
|
+
|
33
|
-
.FullSeriesCollection(newLin).Name = "線形(系統" & j & ")"
|
34
|
-
Next j
|
35
|
-
'.FullSeriesCollection(j).Format.Fill.ForeColor.ObjectThemeColor = msoThemeColorBackground1
|
36
|
-
End With
|
135
|
+
End With
|
37
136
|
|
137
|
+
|
138
|
+
'shName(2)の加工
|
139
|
+
With ActiveSheet.Shapes(shName(2)).Chart
|
140
|
+
For j = 1 To .FullSeriesCollection.Count
|
141
|
+
With .FullSeriesCollection(j)
|
142
|
+
With .Format.Line
|
143
|
+
col = .ForeColor
|
144
|
+
.ForeColor.RGB = msoThemeColorBackground1
|
145
|
+
.Transparency = 1
|
146
|
+
End With
|
147
|
+
'.MarkerBackgroundColor = msoThemeColorBackground1
|
148
|
+
.MarkerForegroundColor = col
|
149
|
+
End With
|
150
|
+
Next
|
151
|
+
With .ChartArea
|
152
|
+
.Fill.Visible = msoFalse
|
153
|
+
.Format.Line.Visible = msoFalse
|
154
|
+
End With
|
155
|
+
With .PlotArea
|
156
|
+
.Format.Fill.Visible = msoFalse
|
157
|
+
.Format.Line.Visible = msoFalse
|
158
|
+
End With
|
159
|
+
With .Axes(xlCategory)
|
160
|
+
.Format.Fill.Visible = msoFalse
|
161
|
+
.Format.Line.Visible = msoFalse
|
162
|
+
.HasMajorGridlines = False
|
163
|
+
.HasMinorGridlines = False
|
164
|
+
.HasTitle = False
|
165
|
+
End With
|
166
|
+
|
167
|
+
With .Axes(xlValue)
|
168
|
+
.Format.Fill.Visible = msoFalse
|
169
|
+
.Format.Line.Visible = msoFalse
|
170
|
+
.HasMajorGridlines = False
|
171
|
+
.HasMinorGridlines = False
|
172
|
+
.HasTitle = False
|
173
|
+
End With
|
174
|
+
End With
|
175
|
+
|
176
|
+
|
177
|
+
'グラフエリアをそろえる
|
178
|
+
With ActiveSheet.Shapes(shName(0))
|
179
|
+
AreaWidth = .Width
|
180
|
+
AreaHeight = .Height
|
181
|
+
|
182
|
+
PlotAreaTop = .Chart.PlotArea.Top + 10
|
183
|
+
PlotAreaLeft = .Chart.PlotArea.Left + 10
|
184
|
+
PlotAreaWidth = .Chart.PlotArea.Width
|
185
|
+
PlotAreaHeight = .Chart.PlotArea.Height
|
186
|
+
End With
|
187
|
+
'プロットエリアをそろえる
|
188
|
+
For Each shpName In shName()
|
189
|
+
With ActiveSheet.Shapes(shpName)
|
190
|
+
.Width = AreaWidth
|
191
|
+
.Height = AreaHeight
|
192
|
+
End With
|
193
|
+
With ActiveSheet.Shapes(shpName).Chart
|
194
|
+
.PlotArea.Top = PlotAreaTop
|
195
|
+
.PlotArea.Left = PlotAreaLeft
|
196
|
+
.PlotArea.Width = PlotAreaWidth
|
197
|
+
.PlotArea.Height = PlotAreaHeight
|
198
|
+
End With
|
199
|
+
Next
|
200
|
+
|
201
|
+
|
202
|
+
'重ね合わせ
|
203
|
+
With ActiveSheet.Shapes(shName(1))
|
204
|
+
.Top = Range("F5").Top '位置を設定
|
205
|
+
.Left = Range("F5").Left
|
206
|
+
.ZOrder msoBringForward
|
207
|
+
End With
|
208
|
+
With ActiveSheet.Shapes(shName(2))
|
209
|
+
.Top = Range("F5").Top '位置を設定
|
210
|
+
.Left = Range("F5").Left
|
211
|
+
.ZOrder msoBringForward
|
212
|
+
End With
|
213
|
+
|
38
214
|
End Sub
|
215
|
+
|
39
216
|
```
|