View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default How to Hilight Chart's Source Data?

This is crude, I'm ashamed to post it, but you might like it !

Sub test()
Dim sf As String
Dim arr, v
Dim rng As Range, rAll As Range
Dim cht As Chart
Dim sr As Series

Set cht = ActiveChart
If cht Is Nothing Then
MsgBox "Select a chart"
Exit Sub
End If

On Error Resume Next
For Each sr In cht.SeriesCollection
sf = sr.Formula
sf = Mid$(sf, 9, Len(sf) - 9) ' strip =SERIES( )
arr = Split(sf, ",")
For Each v In arr
Set rng = Range(v)
If Not rng Is Nothing Then

If rAll Is Nothing Then
Set rAll = rng
Else
Set rAll = Union(rAll, rng)
End If
Set rng = Nothing
End If
Next
Next

If Not rAll Is Nothing Then
Application.Goto rAll
End If

End Sub

Regards,
Peter T

"ryguy7272" wrote in message
...
iI am wondering if there is a way to use code to find cells that a chart
is
linked to. For instance, if I right-click on a chart, and click on Source
Data, I can then see the cells that the chart is linked to in the 'Data
Range' or 'Series' tabs. Can I use a macro to automatically color the
cells
that feed that chart. I would envision clicking on a chart and running
the
code.

Essentially:
ActiveChart.ChartArea.Select
Hilight the cells that are selected...

So, I would just highlight the cells in this range. That way, I can
easily
see the chart's source data. Is that possible?

Thanks,
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.