我正在尝试在工作表上添加散点图,当我手动执行它时它工作得很好,但是当我尝试使用录制的宏时它给我一个 1004 错误
" Sheets("Mapa Riesgos").Shapes.AddChart.Select "
这是代码
Sheets("Mapa Riesgos").Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Range("A11:B35")
With ActiveChart
.Parent.name = "Riesgo Inherente"
.Legend.Delete
.Axes(xlValue).MinimumScale = 0.5
.Axes(xlValue).MaximumScale = 5.5
.Axes(xlCategory).MinimumScale = 0.5
.Axes(xlCategory).MaximumScale = 5.5
.Axes(xlValue).MajorGridlines.Delete
.Axes(xlValue).Delete
.Axes(xlCategory).Delete
.SeriesCollection(1).MarkerStyle = -4142
'chart name
.HasTitle = True
.ChartTitle.Characters.Text = "Riesgo Inherente"
.ChartTitle.Font.Size = 20
'X axis name
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Font.Size = 13
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Impacto"
'y-axis name
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Font.Size = 13
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Probabilidad"
.Parent.Width = 400
.Parent.Height = 400
.Parent.Left = 60
.Parent.Top = 100
End With
我以前使用过这段代码,但由于某种原因,当我在这里使用它时,它只是第一次运行,然后开始出现错误