Reputation: 573
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??
Upvotes: 0
Views: 9266
Reputation: 55682
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.
- 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.
- In the formula bar, type an equal sign (=).
- Select the worksheet cell that contains the data or text that you want to display in the chart.
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.
Upvotes: 0
Reputation: 13655
Use
Chart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text
And
Chart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text
Upvotes: 3