VBAに関しては新人ですが、基本的に複数のシートで実行するために使用できるマクロを作成したいと思います。私はたくさんのデータを持っています。マクロを独立させて、複数のシートをExcelで生成するのに使用する
Excelのマクロ記録機能を使用して、グラフを作成して保存しています。これは正常に動作し、グラフは同じシート上で実行されるたびに生成されます。しかし、別のシートで実行しようとすると、前のシートからグラフが生成されます。私はオンラインで見て、ソース名をActiveSheetに編集しようとしました!それは働いていません。ここに私のコードです:
MinはRET保存
サブminret_v1() ' ' minret_v1マクロ 「誰も私を助けることができる場合
ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(1).Name = "=""0"""
ActiveChart.FullSeriesCollection(1).XValues = _
"='20160916 Acell 1'!$A$6:$A$1033"
ActiveChart.FullSeriesCollection(1).Values = "='20160916 Acell 1'!$B$6:$B$1033"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(2).Name = "=""50"""
ActiveChart.FullSeriesCollection(2).XValues = _
"='20160916 Acell 1'!$A$6:$A$1033"
ActiveChart.FullSeriesCollection(2).Values = _
"='20160916 Acell 1'!$D$953:$D$1033"
ActiveChart.FullSeriesCollection(2).Values = "='20160916 Acell 1'!$D$6:$D$1033"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(3).Name = "=""100"""
ActiveChart.FullSeriesCollection(3).XValues = _
"='20160916 Acell 1'!$A$6:$A$1033"
ActiveChart.FullSeriesCollection(3).Values = "='20160916 Acell 1'!$F$6:$F$1033"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(4).Name = "=""150"""
ActiveChart.FullSeriesCollection(4).XValues = _
"='20160916 Acell 1'!$A$6:$A$1033"
ActiveChart.FullSeriesCollection(4).Values = "='20160916 Acell 1'!$H$6:$H$1033"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(5).Name = "=""200"""
ActiveChart.FullSeriesCollection(5).XValues = _
"='20160916 Acell 1'!$A$6:$A$1033"
ActiveChart.FullSeriesCollection(5).Values = "='20160916 Acell 1'!$J$6:$J$1033"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(6).Name = "=""250"""
ActiveChart.FullSeriesCollection(6).XValues = _
"='20160916 Acell 1'!$A$6:$A$1033"
ActiveChart.FullSeriesCollection(6).Values = "='20160916 Acell 1'!$L$6:$L$1033"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(7).Name = "=""300"""
ActiveChart.FullSeriesCollection(7).XValues = _
"='20160916 Acell 1'!$A$6:$A$1033"
ActiveChart.FullSeriesCollection(7).Values = "='20160916 Acell 1'!$N$6:$N$1033"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(8).Name = "=""350"""
ActiveChart.FullSeriesCollection(8).XValues = _
"='20160916 Acell 1'!$A$6:$A$1033"
ActiveChart.FullSeriesCollection(8).Values = "='20160916 Acell 1'!$P$6:$P$1033"
ActiveWindow.ScrollRow = 993
ActiveWindow.ScrollRow = 987
ActiveWindow.ScrollRow = 970
ActiveWindow.ScrollRow = 945
ActiveWindow.ScrollRow = 897
ActiveWindow.ScrollRow = 761
ActiveWindow.ScrollRow = 494
ActiveWindow.ScrollRow = 431
ActiveWindow.ScrollRow = 356
ActiveWindow.ScrollRow = 237
ActiveWindow.ScrollRow = 214
ActiveWindow.ScrollRow = 165
ActiveWindow.ScrollRow = 142
ActiveWindow.ScrollRow = 109
ActiveWindow.ScrollRow = 89
ActiveWindow.ScrollRow = 80
ActiveWindow.ScrollRow = 52
ActiveWindow.ScrollRow = 46
ActiveWindow.ScrollRow = 38
ActiveWindow.ScrollRow = 37
ActiveWindow.ScrollRow = 35
ActiveWindow.ScrollRow = 34
ActiveWindow.ScrollRow = 32
ActiveWindow.ScrollRow = 31
ActiveWindow.ScrollRow = 29
ActiveWindow.ScrollRow = 28
ActiveWindow.ScrollRow = 25
ActiveWindow.ScrollRow = 16
ActiveWindow.ScrollRow = 8
ActiveWindow.ScrollRow = 1
ActiveChart.ApplyChartTemplate (_
"C:\Users\Santiago\AppData\Roaming\Microsoft\Templates\Charts\Mult Lines_decay.crtx" _
)
ActiveChart.Axes(xlValue).AxisTitle.Select
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "gamma(nm)"
Selection.Format.TextFrame2.TextRange.Characters.Text = "gamma(nm)"
With Selection.Format.TextFrame2.TextRange.Characters(1, 9).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 9).Font
.BaselineOffset = 0
.Bold = msoTrue
.NameComplexScript = "Arial"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Fill.Transparency = 0
.Fill.Solid
.Size = 18
.Italic = msoFalse
.Kerning = 12
.Name = "Arial"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
ActiveChart.Axes(xlCategory).AxisTitle.Select
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = _
"Distance from interaction"
Selection.Format.TextFrame2.TextRange.Characters.Text = _
"Distance from interaction"
With Selection.Format.TextFrame2.TextRange.Characters(1, 25).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 25).Font
.BaselineOffset = 0
.Bold = msoTrue
.NameComplexScript = "Arial"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Fill.Transparency = 0
.Fill.Solid
.Size = 18
.Italic = msoFalse
.Kerning = 12
.Name = "Arial"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
ActiveChart.ChartTitle.Select
ActiveChart.ChartTitle.Text = "Acell 20160916"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Acell 20160916"
With Selection.Format.TextFrame2.TextRange.Characters(1, 14).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 14).Font
.BaselineOffset = 0
.Bold = msoTrue
.NameComplexScript = "Arial"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Fill.Transparency = 0
.Fill.Solid
.Size = 21.6
.Italic = msoFalse
.Kerning = 12
.Name = "Arial"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
ActiveChart.ChartArea.Select
Range("R10").Select
End Subのは
それはずっとだろう感謝。あなたの時間をありがとう。