View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier[_10_] Jon Peltier[_10_] is offline
external usenet poster
 
Posts: 17
Default Source data for chart

Dim rSelection As Range
If TypeName(Selection) = "Range" Then
Set rSelection = Selection
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=rSelection
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
Else
MsgBox "Select a range and try again", vbCritical
Exit Sub
End If

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


wrote in message
ups.com...
I have a similar question. In my case I want to highlight the xy
values for the chart, then chart the data on a scatter plot. The data
are surrounded by other populated columns - so CurrentRegion won't
work. The problem in the skinnied-down macro below is the Range
function takes the hard coded range. How do I pass in the
user-selected range?

Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B4:C10")
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"