Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Using macro to set chart title with a variable month

I have named two cells as range MONTH and YEAR respectively, so that I can
update my report automatically each month.


My macro:

-------
Range("C1").Select
ActiveCell.FormulaR1C1 = _
"=""Sales Performance (YTD ""&MONTH&"" ""&YEAR&"")"""
Range("C2").Select
ActiveCell.FormulaR1C1 = _
"=&YEAR-1&"" Actual vs ""&YEAR&"" Budget vs ""&YEAR&"" Actual"""
-------

This labels the datasheet (cell C1) as the following formula:

="Sales Performance (YTD "&MONTH&" "&YEAR&")"

Which does the trick. However, I want the macro to set the datasheet title
not as a formula, but as text, using MONTH and YEAR as fixed constants, so
that it reads:

Sales Performance (YTD October 2007)

I've tried amending the fomula as follows:

-------
ActiveCell.FormulaR1C1 = _
"Budgeted Trade Lane Performance (YTD " & Month & " " & Year & ")"
-------

but as soon as I type this it conerts MONTH and YEAR to Month and Year, and
gives an error when I try to run the macro. What I believe I need to do is
to Dim Month as MONTH and Year as YEAR at the start of the macro but I'm not
sure how to do this?



I also have a second problem. I need to do a similar thing to the titles of
Chart1, Chart2 and Chart3. But I can't even figure out how to get the macro
to label the chart using a formula, as above. The macro currently reads:

-------
ActiveChart.ChartTitle.Select
Selection.Characters.Text = _
"Sales Performance (YTD October 2007)" & Chr(10) & "2006 Actual vs
2007 Budget vs 2007 Actual"
-------

I've tried replicating the above formula in the same manner, but this just
enters the whole formula as-is, without calling the MONTH and YEAR ranges. I
assume if I can fix the first problem, I can fix the second in the same way?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Using macro to set chart title with a variable month

Bit more info, have already tried adding the following:

Const Month As String = "MONTH"
Const Year As String = "YEAR"

which changes the title to ....YTD MONTH YEAR

and

Const Month As String = MONTH
Const Year As String = YEAR

which fails
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Using macro to set chart title with a variable month

Found a suitable answer he

http://www.microsoft.com/office/comm...2fsettings.xml
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
can chart title be linked to variable cell address? dmhittner Excel Discussion (Misc queries) 5 February 3rd 07 07:54 PM
can variable be used in chart title Paul S. Charts and Charting in Excel 1 December 7th 05 06:11 PM
How do I identify Filter criteria or variable graph title? Excel_loser Excel Discussion (Misc queries) 0 October 4th 05 07:07 PM
Pasting Objects into Chart title and Axis title Sam Charts and Charting in Excel 1 June 6th 05 08:50 PM
Pivot Chart Title variable Tim Charts and Charting in Excel 1 May 24th 05 08:16 PM


All times are GMT +1. The time now is 11:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"