0
votes

I have a static empty chart in Excel, I have a macro which pulls the data from the excel sheet and populates the graph in the chart. Is there a way to set the title for the X axis and the Y axis using the Chart properties in excel??

2
Did you want a programming (VBA) answer, or a formula answer? You can like chart titles to cells without codebrettdj

2 Answers

3
votes

Use

Chart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text

And

Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text
0
votes

You can link the X axis and Y axis titles to cells, so that they automatically update when the cells change

Text below from this Microsoft Article

To easily update a chart or axis title, label, or text box that you have added to a chart, you can link it to a worksheet cell by creating a reference to that worksheet cell. Changes that you make to the worksheet cell will automatically appear in the chart.

  1. On a chart sheet or in an embedded chart, click the title, label, or text box that you want to link to a worksheet cell.
  2. In the formula bar, type an equal sign (=).
  3. Select the worksheet cell that contains the data or text that you want to display in the chart.
  4. If you want to type the reference to the worksheet cell, include the sheet name followed by an exclamation point, for example, Sheet1!F2

    Press ENTER.