0

I am trying to dynamically set a chart object source. The fdc and ldc variables will change over time. I've tried several variations of code; my latest attempt being:

fdc = 26
ldc = 90
ws.ChartObjects("Chart 2").SetSourceData Source:=ws.Range("S" & fdc & ":V" & ldc)

but they all give:

Run-time error '438': Object doesn't support this property or method.

1 Answer 1

2

You're referring to the ChartObject. SetSourceData is a method of the Chart inside the ChartObject.

Try

fdc = 26
ldc = 90
ws.ChartObjects("Chart 2").Chart.SetSourceData Source:=ws.Range("S" & fdc & ":V" & ldc)
Sign up to request clarification or add additional context in comments.

2 Comments

Excellent. I had read this several times when searching for a solution but I didn't see how to apply it to my situation.
It did but I had to wait two minutes before I could mark it as an answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.