I hate lunch

B

Ben H

This is a really interesting one. So I spent all morning working on this. I
got it run perfectly about 20 times and then broke for lunch. I come back
and a gremlin is now maraudering in my code, laying seige to it. Its hiding
in the all the SeriesCollection functions!

With Sheets(strDataName)
Set rng1 = .Range(.Cells(2, 4), _
.Cells(2, 4).End(xlDown))
Set rng2 = .Range(.Cells(2, 3), _
.Cells(2, 3).End(xlDown))

End With

Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:=strChartName
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Name = Sheets(strDataName).Cells(1, 4)
ActiveChart.SeriesCollection(1).XValues = rng1
ActiveChart.SeriesCollection(1).Values = rng2

Any idea at all would cure this?

Ben H.
 
N

N10

HI Ben

I got the following to work after including your Sheet name in quotes. :)


With Sheets("strDataName")
Set rng1 = .Range(.Cells(2, 4), _
.Cells(2, 4).End(xlDown))
Set rng2 = .Range(.Cells(2, 3), _
.Cells(2, 3).End(xlDown))

End With

Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.Location Where:=xlLocationAsNewSheet
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Name = Sheets("strDataName").Cells(1, 4)
ActiveChart.SeriesCollection(1).XValues = rng1
ActiveChart.SeriesCollection(1).Values = rng2


Happy ploting :)

N10
 

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

Similar Threads

Check for Data series 1
Floating Chart? 2
How to change the row number in macro code? 1
chart range to include variables - Macro 1
Bubble Chart 1
add a chart in a Add-In 1
Help 0
Error Creating Chart 1

Top