setting XValues property when charting using macros

R

rhsiao

Hello,

I hope this message finds you well. I had a quick question concering
XValues syntax.

I am trying to set the XValues of series 3 in Chart 1 of Sheet1. I am
trying to use the values within cells C33 to C35 for the XValues.

The code I am using is listed as follows:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection.NewSeries

ActiveChart.SeriesCollection(3).XValues =
Worksheets("Sheet1").Range(.Cells(33, 3), .Cells(35, 3))


Apparently, there is compile error when I use .Cell in my code. The error
message is: Invalid or unqualified reference. I've checked the syntax
against the VB reference manuals, and it appears correct.

Does anybody have any ideas? Thanks and have a wonderful day!
 
A

Andy Pope

Hi,

You would use .Cells within a With block. The following is untested but
the syntax should work.

With Worksheets("Sheet1")
ActiveChart.SeriesCollection(3).XValues =
.Range(.Cells(33, 3), .Cells(35, 3))
End with

Cheers
Andy
 
R

rhsiao

Mr. Pope,

I'm not sure if you check old threads, but I wanted to thank you for your
help. Your tip was right on! Thanks!
 
A

Andy Pope

Thanks for letting us know.

Cheers
Andy
Mr. Pope,

I'm not sure if you check old threads, but I wanted to thank you for your
help. Your tip was right on! Thanks!



:
 

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