voyagerphoen
01-07-2019, 01:49 AM
In my case it is the property "Name" which appears in lowercase i.e. "name".I have not declared it as variable but it still shows as so.but it successfully runs code. Please help.Here is the code
Sub Oh(chtname As String, chtsheet As String, chtrange As String, chttitle As String, chtaxistitlecategory As String, chtaxistitlevalue As String)
On Error GoTo ErrorHandling
With Charts(chtname)
.ChartType = xlColumnClustered
.HasTitle = True
.ChartTitle.Text = chttitle
.SetSourceData Source:=Sheets(chtsheet).Range(chtrange), PlotBy:=xlRows
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = chtaxistitlecategory
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = chtaxistitlevalue
End With
Exit Sub
ErrorHandling:
MsgBox "No charts found create one ?"
Charts.Add
ActiveChart.name = chtname
Resume
End Sub
Sub callOh()
Call Oh("MyChart", "ChSheet", "A1:D9", "ExCh", "Month", "Sales")
End Sub
Sub Oh(chtname As String, chtsheet As String, chtrange As String, chttitle As String, chtaxistitlecategory As String, chtaxistitlevalue As String)
On Error GoTo ErrorHandling
With Charts(chtname)
.ChartType = xlColumnClustered
.HasTitle = True
.ChartTitle.Text = chttitle
.SetSourceData Source:=Sheets(chtsheet).Range(chtrange), PlotBy:=xlRows
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = chtaxistitlecategory
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = chtaxistitlevalue
End With
Exit Sub
ErrorHandling:
MsgBox "No charts found create one ?"
Charts.Add
ActiveChart.name = chtname
Resume
End Sub
Sub callOh()
Call Oh("MyChart", "ChSheet", "A1:D9", "ExCh", "Month", "Sales")
End Sub