Hi all,
I am trying to create a chart on userform.but unfortunately the code generates error "Copile Error - can not find Project and Library" when we choose chart type -".Type = chChartTypeBarClustered"
Option Explicit
Private Sub UserForm_Initialize()
'Spreadsheet1.Visible = False
With ChartSpace1
' Add a chart.
.Charts.Add
' Set the data source of the chart to the Spreadsheet control.
.DataSource = Spreadsheet1
With .Charts(0)
' Create a bar chart.
.Type = chChartTypeBarClustered
.SeriesCollection.Add
' Set the properties of data series.
With .SeriesCollection(0)
.SetData chDimSeriesNames, 0, "B1"
.SetData chDimCategories, 0, "A2:A15"
.SetData chDimValues, 0, "B2:B15"
End With
' Display the legend.
.HasLegend = True
End With
End With
End Sub
Please help.........
I am trying to create a chart on userform.but unfortunately the code generates error "Copile Error - can not find Project and Library" when we choose chart type -".Type = chChartTypeBarClustered"
Option Explicit
Private Sub UserForm_Initialize()
'Spreadsheet1.Visible = False
With ChartSpace1
' Add a chart.
.Charts.Add
' Set the data source of the chart to the Spreadsheet control.
.DataSource = Spreadsheet1
With .Charts(0)
' Create a bar chart.
.Type = chChartTypeBarClustered
.SeriesCollection.Add
' Set the properties of data series.
With .SeriesCollection(0)
.SetData chDimSeriesNames, 0, "B1"
.SetData chDimCategories, 0, "A2:A15"
.SetData chDimValues, 0, "B2:B15"
End With
' Display the legend.
.HasLegend = True
End With
End With
End Sub
Please help.........