Complete the code to create a column chart from data in cells A1 to B5.
ActiveSheet.Shapes.AddChart2(251, [1], Left:=100, Top:=50, Width:=400, Height:=300).Chart.SetSourceData Source:=Range("A1:B5")
The xlColumnClustered constant creates a clustered column chart, which is the standard column chart type.
Complete the code to set the chart title to 'Sales Data'.
With ActiveSheet.ChartObjects(1).Chart .HasTitle = True .ChartTitle.Text = [1] End With
The chart title text must be a string enclosed in double quotes.
Fix the error in the code to change the chart type to a bar chart.
ActiveSheet.ChartObjects(1).Chart.ChartType = [1]
The correct constant for a clustered bar chart is xlBarClustered. It must be used exactly as is.
Fill both blanks to add data labels showing values on the chart.
With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1) .HasDataLabels = [1] .DataLabels.ShowValue = [2] End With
Setting HasDataLabels to True enables data labels, and ShowValue = True shows the values on the labels.
Fill all three blanks to create a bar chart, set the title to 'Expenses', and show data labels.
With ActiveSheet.Shapes.AddChart2(251, [1], Left:=50, Top:=50, Width:=400, Height:=300).Chart .SetSourceData Source:=Range("A1:B5") .HasTitle = True .ChartTitle.Text = [2] .SeriesCollection(1).HasDataLabels = [3] End With
Use xlBarClustered for a bar chart, the title must be a string in quotes, and HasDataLabels set to True shows the labels.