Hello,

I have written some VBA code to create a plot. The code asks the user to select a range of data. The weird thing is that if I select a small range of data, the titles will appear. However, for large ranges of data, it won't. Does anyone have any experience with this?

Here is my code:

Private Sub CommandButton2_Click()
'Create Plot
Dim Rng As Range
Dim cht As Chart

Dim Title As String
Dim Xtitle As String
Dim Ytitle As String




Set cht = ActiveSheet.Shapes.AddChart(XlChartType:=xlXYScatter).Chart


On Error GoTo Cancelled
Set Rng = Application.InputBox(Prompt:="Range to format:", Title:="Format Range", Type:=8)
With cht
.SetSourceData Source:=Rng
.HasTitle = True
.ChartTitle.Text = "Title"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "X"
'y-axis name
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Y"


End With
Cancelled:
End Sub