ejortberg
asked on
VBA to change formula in data label
Hello,
I used Rob Bovey's xy chart labeler to label a dataseries in a scatterplot. Each datalabel refers to a cell in the worksheet, such as "=BE_Cat!$D$30", so the data label contains whatever is in cell d30, d31 etc.
Unfortunately, I (or Excel) screwed up and have many, many files and charts where the label formula refers to the wrong sheet, e.g. "=CV_Cat!$D$30" instead of "=BE_Cat!$D$30".
To fix this, I'm looking for a macro to select a certain dataseries in a chart (Let's call it "CV"), and then circle through all the data labels in the series to change "CV" to "BE" in the label formula, i.e. from "=CV_Cat!$D$30" to "=BE_Cat!$D$30", "=CV_Cat!$D$31" to "=BE_Cat!$D$31", and so on.
Thank you!!!!
I used Rob Bovey's xy chart labeler to label a dataseries in a scatterplot. Each datalabel refers to a cell in the worksheet, such as "=BE_Cat!$D$30", so the data label contains whatever is in cell d30, d31 etc.
Unfortunately, I (or Excel) screwed up and have many, many files and charts where the label formula refers to the wrong sheet, e.g. "=CV_Cat!$D$30" instead of "=BE_Cat!$D$30".
To fix this, I'm looking for a macro to select a certain dataseries in a chart (Let's call it "CV"), and then circle through all the data labels in the series to change "CV" to "BE" in the label formula, i.e. from "=CV_Cat!$D$30" to "=BE_Cat!$D$30", "=CV_Cat!$D$31" to "=BE_Cat!$D$31", and so on.
Thank you!!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You may include a check for an actual formula
since .Formula will return the data label's .Text if it isn't a "real" formula.
If Left$(p.DataLabel.Formula, 1) = "=" Then
since .Formula will return the data label's .Text if it isn't a "real" formula.
ASKER