PDA

View Full Version : Solved: How To Automatic Set The Data Source Of A Chart?



Erdin? E. Ka
11-20-2006, 09:44 AM
Hi everyone:hi:

One of our member on T?rkiye Board asked a question about how to automatic set a data source of a chart?

I tried some methods to solve it but i couldn't. :dunno

Can somebody help me please?

I attached the file.

And the wrong codes:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim LastRow
Set Sheet = Sheets("Sheet1")
LastRow = WorksheetFunction.CountA(Sheet.Range("A:A"))
ActiveChart.SetSourceData Source:=Sheet.Range("A1:B" & LastRow), PlotBy:=xlColumns
End Sub


(Actually i want to learn VBA VBA method a and via Formula method to solve it, if it possible. )

Thanks in adnavce.

Ken Puls
11-20-2006, 10:36 AM
Hi Erdinc,

I don't have time to look into this myself right now... have you checked out Jon Peltier's Site (www.peltiertech.com)? His is usually my first stop for any charting questions. Andy Pope (www.andypope.info) also has some good charting stuff as well.

Erdin? E. Ka
11-20-2006, 12:14 PM
Hi Ken, :hi:

I solved the problem via Name - Define method. : pray2: :thumb

But i didn't fould a way with VBA. But its not important. Finally i solved it.

Thanks a lot for kindly help. :friends:

SherryO
04-12-2007, 12:14 PM
Hi - this is exactly what I'm trying to do. You don't happen to have the instructions in English, do you. I sure would appreciate it. Thanks!!

lucas
04-12-2007, 12:31 PM
Add this to the code module for the sheet you wish to have a chart on. create your data and then create the chart and it will be dynamic in 2 directions...
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
For Each c In ChartObjects
n = c.Chart.SeriesCollection(1).Formula
n = Left(n, InStrRev(n, ",") - 1)
n = Right(n, (Len(n) - InStrRev(n, ",")))
c.Chart.SetSourceData Source:=Range(n).CurrentRegion
Next c
End Sub

jolivanes
04-12-2007, 02:37 PM
How about Tushar Mehta's site?

http://www.tushar-mehta.com/excel/newsgroups/dynamic_charts/index.html

Regards.
John