close

How do i set the chart location to create a new sheet called
quot;RiskMatrixquot; the first time the create chart button is pressed and then

have it replace the old quot;RiskMatrixquot; chart everytime it is pressed
again. Here is my CodePrivate Sub CommandButton1_Click()

Sheets(quot;Reportquot;).Activate

Dim WS As Worksheet
Dim Cht As Chart
Dim Rng As Range
Dim iRow As Long

Set WS = ActiveSheet
Set Cht = Charts.Add
Cht.ChartType = xlXYScatter

Set Rng = WS.Range(WS.Range(quot;A2quot;), WS.Range(quot;A2quot;).End(xlDown))For iRow = 2 To 1 Rng.Rows.Count
Cht.SeriesCollection.NewSeries
With Cht.SeriesCollection(iRow - 1)
.XValues = quot;='quot; amp; WS.name amp; quot;'!Rquot; amp; iRow amp; quot;C4quot;
.Values = quot;='quot; amp; WS.name amp; quot;'!Rquot; amp; iRow amp; quot;C3quot;
.name = quot;='quot; amp; WS.name amp; quot;'!Rquot; amp; iRow amp; quot;C1quot;
.ApplyDataLabels AutoText:=True, LegendKey:= _
False, ShowSeriesName:=True, ShowCategoryName:=False,
ShowValue:=False, _
ShowPercentage:=False, ShowBubbleSize:=False
End With

Next

With Cht
.HasTitle = True
.ChartTitle.Text = quot;riskquot;
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Text = quot;Impactquot;
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Text = quot;Probabilityquot;
.HasAxis(xlCategory, xlPrimary) = False
.HasAxis(xlValue, xlPrimary) = False
.HasLegend = False
End With
With Cht.Axes(xlCategory)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
With Cht.Axes(xlValue)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With

End Sub

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()