【发布时间】:2021-05-25 12:41:58
【问题描述】:
我想要我提取的数据以在县级插入州地图,但还要添加适当的标题并更改图表内“格式化数据系列”工具栏中的发散间隔。
我记录了这个过程,代码将插入状态图,但不会进行我想要的编辑。
我的数据标题是:州县比率。
这是我记录的代码:
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWindow.SmallScroll Down:=-90
ActiveSheet.Shapes.AddChart2(494, xlRegionMap).Select
ActiveSheet.ChartObjects("Chart 8").Activate
ActiveChart.PlotArea.Select
ActiveChart.ChartTitle.Select
Selection.Caption = "NCAT LR by County"
ActiveChart.FullSeriesCollection(1).Select
ActiveChart.FullSeriesCollection(1).SeriesColorGradientStyle = _
xlSeriesColorGradientStyleDiverging
ActiveChart.FullSeriesCollection(1).SeriesColorMinGradientStop. _
StopPositionType = xlGradientStopPositionTypeNumber
ActiveChart.FullSeriesCollection(1).SeriesColorMinGradientStop.StopValue = _
"-0.102"
ActiveChart.FullSeriesCollection(1).SeriesColorMidGradientStop. _
StopPositionType = xlGradientStopPositionTypeNumber
ActiveChart.FullSeriesCollection(1).SeriesColorMidGradientStop.StopValue = _
"0.81"
ActiveChart.FullSeriesCollection(1).SeriesColorMaxGradientStop. _
StopPositionType = xlGradientStopPositionTypeNumber
ActiveChart.FullSeriesCollection(1).SeriesColorMaxGradientStop.StopValue = _
"1.721"
With ActiveChart.FullSeriesCollection(1)
.SeriesColorMinGradientStop.StopColor.RGB = 5287936
.SeriesColorMinGradientStop.StopColor.TintAndShade = 0
.SeriesColorMinGradientStop.StopColor.Transparency = 0
End With
With ActiveChart.FullSeriesCollection(1)
.SeriesColorMidGradientStop.StopColor.ObjectThemeColor = 2
.SeriesColorMidGradientStop.StopColor.TintAndShade = 0
.SeriesColorMidGradientStop.StopColor.Transparency = 0
End With
With ActiveChart.FullSeriesCollection(1)
.SeriesColorMaxGradientStop.StopColor.RGB = 255
.SeriesColorMaxGradientStop.StopColor.TintAndShade = 0
.SeriesColorMaxGradientStop.StopColor.Transparency = 0
End With
ActiveChart.FullSeriesCollection(1).SeriesColorMinGradientStop.StopValue = "0"
ActiveChart.FullSeriesCollection(1).SeriesColorMidGradientStop.StopValue = _
"0.50"
ActiveChart.FullSeriesCollection(1).SeriesColorMaxGradientStop.StopValue = "1"
Application.CommandBars("Format Object").Visible = False
第一个错误出现在“ActiveSheet.ChartObjects("Chart 8").Activate”的地方,错误消息是:
“运行时错误'-2147024809 (80070057)'
【问题讨论】: