Assign Chart Title w/ VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is a cross-post from "Programming" yesterday - There were no replies

Last month, Jon Peltier was kind enough to give me the below code to set a Chart's Title

With ActiveWorkbook.Worksheets("OneMonth").ChartObjects(2).Char
.HasTitle = Tru
.ChartTitle.Text = "Monthly Scrap Dollars
End Wit

My question, I am not able to concatenate a named Range like..
.ChartTitle.Text = "Monthly Scrap Dollars " & ATitle ---> where ATitle is a named range filled i
thru automation within Access (yes it works from Access)...IE "From 1/1/04 To 1/19/04

I am trying similar code, but it won't work...only a string w/o concatenation is working

Can it be done

TIA - Bo
 
Bob -

Is ATitle a VBA variable for an Excel range, a string holding the range
name, or the contents of the cell named in the range?

If ATitle is a string with the value of the named range, your statement
would work. If ATitle is a VBA range variable, the statement should
work, although ATitle.Value is the full syntax (Value is the default
property of a range object). If ATitle is the name of a range in the
sheet named OneMonth, your statement should be:

.ChartTitle.Text = "Monthly Scrap Dollars" & _
Worksheets("OneMonth").Range(ATitle).Value

- Jon
 
Jon - You're a Champ.

I did change --
.ChartTitle.Text = "Monthly Scrap Dollars" & _
Worksheets("OneMonth").Range("ATitle").Value
Added " " around ATitle.

Thank you - Bob

----- Jon Peltier wrote: -----

Bob -

Is ATitle a VBA variable for an Excel range, a string holding the range
name, or the contents of the cell named in the range?

If ATitle is a string with the value of the named range, your statement
would work. If ATitle is a VBA range variable, the statement should
work, although ATitle.Value is the full syntax (Value is the default
property of a range object). If ATitle is the name of a range in the
sheet named OneMonth, your statement should be:

.ChartTitle.Text = "Monthly Scrap Dollars" & _
Worksheets("OneMonth").Range(ATitle).Value

- Jon
 
Back
Top