Private Sub OptionButton1_Click()
ActiveSheet.Range("F2").Select
Dim wks As Worksheet
For Each wks In Worksheets
If wks.ChartObjects.Count > 0 Then
wks.ChartObjects.Delete
End If
Next wks
Dim rng As Range
Dim cht As ChartObject
Set rng = ActiveWorkbook.Sheets("REPORT DATA").Range("D2:AI10")
Set cht = ActiveSheet.ChartObjects.Add( _
Left:=ActiveCell.Left, _
Width:=1180, _
Top:=ActiveCell.Top, _
Height:=548)
If Range("I38") >= Range("K38") Then
MsgBox "Wrong date value, please check your enrty.", vbCritical, "Error"
Else
cht.Chart.SetSourceData Source:=rng
cht.Chart.ChartType = xlXYScatterLines
cht.Chart.SetElement (msoElementDataLabelCenter)
cht.Chart.ChartArea.Format.TextFrame2.TextRange.Font.size = 8
cht.Chart.HasTitle = True
cht.Chart.ChartTitle.Text = "LEONARDO - MounterTrace Size with Index Line 1 to 8"
cht.Chart.Axes(xlCategory).MinimumScale = Range("I38")
cht.Chart.Axes(xlCategory).MaximumScale = Range("K38")
cht.Chart.ChartArea.Format.Fill.Visible = msoFalse
cht.Chart.PlotArea.Format.Fill.Visible = msoFalse
End If
End Sub
Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.
TRUSTED BY
ASKER