SeriesCollection Question

B

Brad

I'm trying to auto adjust a chart. Here is the code I'm using.

a is a user defined variable (in the current setup i'm using a = 15)

With Charts("Chart1")

.SeriesCollection(1).Name = "=RawData!$D$1"

.SeriesCollection(1).Values = _
Worksheets("RawData").Range(Cells(3, 6), Cells(a, 6)) <- Problem Line

End With

When I run this I get a app-def or obj-def error. Any help will be appreciated
 
P

paul.robinson

Hi
Your range reference will fail unless Worksheets("RawData") is the
active sheet. If it is not, you will need

Worksheets("RawData").Range(Worksheets("RawData").Cells(3, 6),
Worksheets("RawData").Cells(a, 6))
or
With Worksheets("RawData")
.Range(.Cells(3, 6), .Cells(a, 6))
End with

regards
Paul
 

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