ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Plot Ranges (https://www.excelbanter.com/excel-programming/402063-plot-ranges.html)

MikeM

Plot Ranges
 
I can write

With ActiveChart
.ChartType = xlXYScatterLinesNoMarkers
.SetSourceData Source:=Sheets(1).Range(Cells(1, 1), Cells(15, 2))
End With

but this doesn't work

setrA = Sheets(1).Range(Cells(1, 1), Cells(15, 2))
With ActiveChart
.ChartType = xlXYScatterLinesNoMarkers
.SetSourceData Source:=rA
End With

Can someone explain why? [I don't want just a fix, but an understanding of
plotting procedures.

TIA,
Mike

JLGWhiz

Plot Ranges
 
When you use the With ActiveChart and then tell it the source is in in
Range(Cells.... it does not find Cells with ActiveChart. Although you
thought you qualified the Cells with Worksheets(1), VBA don't acknowledge it.
So in the second case where you first qualified the range by setting it to
Worksheets(1) in a variable before trying to apply it, it does acknowledge
it. I do the same thing repetitively and I should know better.

"MikeM" wrote:

I can write

With ActiveChart
.ChartType = xlXYScatterLinesNoMarkers
.SetSourceData Source:=Sheets(1).Range(Cells(1, 1), Cells(15, 2))
End With

but this doesn't work

setrA = Sheets(1).Range(Cells(1, 1), Cells(15, 2))
With ActiveChart
.ChartType = xlXYScatterLinesNoMarkers
.SetSourceData Source:=rA
End With

Can someone explain why? [I don't want just a fix, but an understanding of
plotting procedures.

TIA,
Mike


MikeM

Plot Ranges
 
Actually, the opposite is true. The first version worked but the second didn't.

"JLGWhiz" wrote:

When you use the With ActiveChart and then tell it the source is in in
Range(Cells.... it does not find Cells with ActiveChart. Although you
thought you qualified the Cells with Worksheets(1), VBA don't acknowledge it.
So in the second case where you first qualified the range by setting it to
Worksheets(1) in a variable before trying to apply it, it does acknowledge
it. I do the same thing repetitively and I should know better.

"MikeM" wrote:

I can write

With ActiveChart
.ChartType = xlXYScatterLinesNoMarkers
.SetSourceData Source:=Sheets(1).Range(Cells(1, 1), Cells(15, 2))
End With

but this doesn't work

setrA = Sheets(1).Range(Cells(1, 1), Cells(15, 2))
With ActiveChart
.ChartType = xlXYScatterLinesNoMarkers
.SetSourceData Source:=rA
End With

Can someone explain why? [I don't want just a fix, but an understanding of
plotting procedures.

TIA,
Mike



All times are GMT +1. The time now is 09:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com