Extract the value from a cell, and add it to a chart title

A

Art

H
I'm trying to take the value from a cell on a different worksheet, and add it to some text for a chart title
I presently have
Dim BarnName as Strin
BarnName = ActiveChart.ChartTitle = "=data!R6c1
ActiveChart.ChartTitle.Characters.Text = BarnNam

I know the second line isn't correct, but I'm not sure how to write it

TI
Art
 
E

Edwin Tam

The macro should look like this

Sub Assign_Chart_Title(
ActiveChart.ChartTitle.Characters.Text = Worksheets("data").Range("A7").Valu
End Su

To use the macro, select the chart, and run the macro

Regards
Edwin Ta
[email protected]
http://www.vonixx.co


----- Art wrote: ----

H
I'm trying to take the value from a cell on a different worksheet, and add it to some text for a chart title
I presently have
Dim BarnName as Strin
BarnName = ActiveChart.ChartTitle = "=data!R6c1
ActiveChart.ChartTitle.Characters.Text = BarnNam

I know the second line isn't correct, but I'm not sure how to write it

TI
Art
 
C

Cecilkumara Fernando

Art,
Try
BarnName = ActiveChart.ChartTitle.Text & " " & _
sheets("Data").cells(6, 1).value
ActiveChart.ChartTitle.Text = BarnName
Cecil

Art said:
Hi
I'm trying to take the value from a cell on a different worksheet, and add
it to some text for a chart title.
 
J

Jon Peltier

If you want this to be dynamic, put the formula with the added text into
a cell, and link the title to the cell.

C1 has text, C2 has a value, put this into C3:

=C1&TEXT(C2,"0.00")

Use some appropriate number format, or you may get something unexpected.

Now select the chart title, press the = key, and select C3 with the mouse.

To link the title to the cell in VBA, use:

ActiveChart.ChartTitle.Text = _
"=" Sheets("Data").Cells(3,3).AddressR1C1(External:=True)

You need to specify this address in RC notation, and External:=True
includes the qualified sheet name.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
Top