I have the following VBA application, but I cannot get the chart title to set to cell “B2” text and to position title above chart and then to get the range that is used for the chart to use data up until the last row of different size ranges.
Please see my code application in VBA below. I have been struggling to format and modify this for the past three days. Please help me where possible.
`your text``Sub Macro_Histogram_VariableRange()`your text`
'
' `your text`Macro_Histogram_VariableRange Macro`your text`
'
` `your text`MsgBox "Histogram being created"`your text`
`your text`Dim lastrow As Integer`your text`
`your text`lastrow = Cells(Rows.Count, 1).End(xlUp).Row`your text`
`your text`If Range("F5").Value <> "F" Then`your text`
`your text`Exit Sub`your text`
`your text`Else`your text`
'
`your text`Range("E6:E402").Select
`your text`ActiveSheet.Shapes.AddChart2(366, xlHistogram).Select`your text`
`your text`ActiveSheet.ChartObjects("Chart 1").Activate`your text`
`your text`AddingAndSettingAChartTitle()`your text`
`your text`ActiveChart.SetElement (msoElementChartTitleAboveChart)`your text`
`your text`ActiveChart.ChartTitle.Text = "B2"`your text`
`your text`End Sub`your text`
That is the first part of my VBA application modification.
The problem is that it gives me a syntax code error (“Can’t execute code in break mode”), and the highlights certain things in VBA Application window.
Below is the screenshot.
issue with the sub heading or description. It is highlighted
Taryn Shedlock is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1