View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Ryan Bob Ryan is offline
external usenet poster
 
Posts: 8
Default Auto insert sheetname into chart title?

On 5/8/2010 5:26 PM, Ian R wrote:

Hi

I'm using Excel 2003

I have several charts on a worksheet.

At the end of each month I copy the sheet to become the first worksheet
in the workbook, delete the data and rename the sheet for the following
month.

All my charts have a chart title e.g "Total income for April 2010". The
sheetname is April 2010. When I copy this sheet to become "May 2010" I
then have to manually edit all the chart titles on that sheet.

I wondered if there is a way to reference the sheetname in the chart
title so that when I rename the sheet the chart titles automatically
update.

Thanks for your time.

Ian


I don't think there's a way to reference a sheet name in a chart title,
but you may want to consider using a macro (VBA).

For example, the macro below will put the title "Total Income for April,
2010" in the chart title for Chart 1 and Chart 2 in the sheet named
"April, 2010." Next month, change the sheet name to "May, 2010," use
EditReplace to change every occurrence of the word "April" to "May" in
the macro, and run it. If you have charts on more than one sheet, you
can adjust the sheet names as necessary.

Sheets("April, 2010").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartTitle.Text = "Total Income for April, 2010"
Sheets("April, 2010").Select
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartTitle.Text = "Total Income for April, 2010"

Hope this helps.
Bob Ryan