У меня проблема с макросом, который я записал в Excel.
Макрос:
вставляет 2 графика
выбирает 1-й график
Помещает определенные данные на вторичную вертикальную ось
Макрос работает до строки ниже и даетошибка:
ActiveSheet.ChartObjects («Диаграмма 17»). Активируйте
Кто-нибудь знает, как можно избавиться от части «Диаграмма 17» и заменить ее чем-то, что делаетне нужно ссылаться на диаграмму 17 или нумерованную диаграмму?
Заранее спасибо
РЕДАКТИРОВАТЬ - Извинения, ниже приведен код для создания работающего графика и редактирования графика, который не
Sub PLOTGraph()
Range("B:B,D:D,F:F,H:H,J:J,L:L").Select
Range("L1").Activate
ActiveWindow.SmallScroll ToRight:=9
Range("B:B,D:D,F:F,H:H,J:J,L:L,N:N,P:P,R:R,T:T").Select
Range("T1").Activate
ActiveWindow.SmallScroll ToRight:=10
Range("B:B,D:D,F:F,H:H,J:J,L:L,N:N,P:P,R:R,T:T,V:V,X:X,Z:Z,AB:AB,AD:AD").Select
Range("AD1").Activate
ActiveWindow.SmallScroll ToRight:=7
Range( _
"B:B,D:D,F:F,H:H,J:J,L:L,N:N,P:P,R:R,T:T,V:V,X:X,Z:Z,AB:AB,AD:AD,AF:AF,AH:AH,A J:AJ,AL:AL" _
).Select
Range("AL1").Activate
ActiveWindow.SmallScroll ToRight:=8
Range( _
"B:B,D:D,F:F,H:H,J:J,L:L,N:N,P:P,R:R,T:T,V:V,X:X,Z:Z,AB:AB,AD:AD,AF:AF,AH:AH,A J:AJ,AL:AL,AN:AN,AP:AP,AR:AR,AT:AT" _
).Select
Range("AT1").Activate
ActiveWindow.SmallScroll ToRight:=7
Range( _
"B:B,D:D,F:F,H:H,J:J,L:L,N:N,P:P,R:R,T:T,V:V,X:X,Z:Z,AB:AB,AD:AD,AF:AF,AH:AH,A J:AJ,AL:AL,AN:AN,AP:AP,AR:AR,AT:AT,AV:AV" _
).Select
Range("AV1").Activate
ActiveSheet.Shapes.AddChart2(240, xlXYScatterLinesNoMarkers).Select
End Sub
Sub PREPGRAPH()
ActiveSheet.ChartObjects("Chart 17").Activate
ActiveSheet.Shapes("Chart 17").IncrementLeft 307.4175590551
ActiveSheet.Shapes("Chart 17").IncrementTop -7.4175590551
ActiveSheet.ChartObjects("Chart 17").Activate
ActiveSheet.Shapes("Chart 17").ScaleWidth 2.2901131822, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Chart 17").ScaleHeight 2.4446731852, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.ChartObjects("Chart 17").Activate
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(13).Select
ActiveChart.Legend.LegendEntries(12).Select
ActiveChart.FullSeriesCollection(12).Select
ActiveChart.FullSeriesCollection(12).AxisGroup = 2
ActiveSheet.ChartObjects("Chart 17").Activate
ActiveChart.FullSeriesCollection(12).Select
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(12).Select
ActiveChart.FullSeriesCollection(13).Select
ActiveChart.FullSeriesCollection(13).AxisGroup = 2
ActiveSheet.ChartObjects("Chart 17").Activate
ActiveChart.FullSeriesCollection(13).Select
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(12).Select
ActiveChart.FullSeriesCollection(14).Select
ActiveChart.FullSeriesCollection(14).AxisGroup = 2
ActiveSheet.ChartObjects("Chart 17").Activate
ActiveChart.FullSeriesCollection(14).Select
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(12).Select
ActiveChart.FullSeriesCollection(15).Select
ActiveChart.FullSeriesCollection(15).AxisGroup = 2
ActiveSheet.ChartObjects("Chart 17").Activate
ActiveChart.FullSeriesCollection(15).Select
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(12).Select
ActiveChart.FullSeriesCollection(16).Select
ActiveChart.FullSeriesCollection(16).AxisGroup = 2
ActiveSheet.ChartObjects("Chart 17").Activate
ActiveChart.FullSeriesCollection(16).Select
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleAdjacentToAxis)
ActiveChart.SetElement (msoElementSecondaryValueAxisTitleAdjacentToAxis)
ActiveChart.Axes(xlValue).AxisTitle.Select
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = _
"Voltage (V) & Temperature (?)"
Selection.Format.TextFrame2.TextRange.Characters.Text = _
"Voltage (V) & Temperature (?)"
With Selection.Format.TextFrame2.TextRange.Characters(1, 29).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 7).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 10
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
With Selection.Format.TextFrame2.TextRange.Characters(8, 20).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 10
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
With Selection.Format.TextFrame2.TextRange.Characters(28, 2).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "Times New Roman"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 10
.Italic = msoFalse
.Kerning = 12
.Name = "Times New Roman"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
ActiveChart.Axes(xlCategory).AxisTitle.Select
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "Time (s)"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Time (s)"
With Selection.Format.TextFrame2.TextRange.Characters(1, 8).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 8).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 10
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
ActiveChart.Axes(xlValue, xlSecondary).AxisTitle.Select
ActiveChart.Axes(xlValue, xlSecondary).AxisTitle.Text = "Voltage (V)"
Selection.Format.TextFrame2.TextRange.Characters.Text = "Voltage (V)"
With Selection.Format.TextFrame2.TextRange.Characters(1, 11).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With Selection.Format.TextFrame2.TextRange.Characters(1, 11).Font
.BaselineOffset = 0
.Bold = msoFalse
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(89, 89, 89)
.Fill.Transparency = 0
.Fill.Solid
.Size = 10
.Italic = msoFalse
.Kerning = 12
.Name = "+mn-lt"
.UnderlineStyle = msoNoUnderline
.Strike = msoNoStrike
End With
End Sub