Data Label Value in Formula?

P

Phil Hageman

Is it possible to use a data label value in a formula? How would this be done?

Thanks, Phil
 
F

Frank Kabel

Hi
it is. But maybe give some more details what you're trying to achieve
exactly
 
J

John Mansfield

Phil,

I may not be understanding your question but would a macro like the example
below do? It extracts the text in the first series data label to an variable
of the integer type and then references that variable in a formula in cell
A1. In this example, the formula would look like "= 6 + your label value +
4". Click on your chart to activate it and then run the macro. If it works
for you, it would need to be modified to your specs:

Sub DataLabelTextToFormula()
Dim Cht As Chart
Dim Val As Integer
Set Cht = ActiveChart
Cht.SeriesCollection(1).ApplyDataLabels Type:=xlDataLabelsShowValue
Val = Cht.SeriesCollection(1).Points(1).DataLabel.Text
Worksheets("Sheet1").Range("A1").Formula = "=6+" & Val & "+4"
End Sub

Other than that, you can always direct reference the data source in your
formula as it is the same source for the data label.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top