• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Is it Possible - Live chart

Dear Expert solvers,


We had a scenario where needs to fulfill as when data as


Data

A B C D E

row1 12 23 44 55 65


Requirement

When i place my cursor in B1 it has to show graph(trend) by fetching A1 & B1

whreas when i place at column E it has to show graph upto E by fetching data A1 ~ E1


Hope it can be solved !!
 
Hi, senthilkumar_rm!


Give a look at this file:

https://dl.dropbox.com/u/60558749/Is%20it%20Possible%20-%20Live%20chart%20%28for%20senthilkumar_rm%20at%20chandoo.org%29.xlsm


The worksheet structure is as this and starts in cell A1:

-----

[pre]
Code:
Name	31/01/2012	29/02/2012	31/03/2012	30/04/2012	...
Uma	1		10		3		1		...
Milla	7		6		5		4		...
Kate	3		3		9		7		...
-----


It has 2 dynamic named ranges:

a) DataTable

=DESREF(Hoja1!$A$1;0;0;CONTARA(Hoja1!$A:$A);CONTARA(Hoja1!$1:$1)) -----> in english: =OFFSET(Hoja1!$A$1,0,0,CONTARA(Hoja1!$A:$A),CONTARA(Hoja1!$1:$1))

b) DataChart

=DESREF(DataTable;0;0;;2) -----> in english: =OFFSET(DataTable,0,0,,2)


Chart is named MyFansChart.


It uses this litle piece of VBA code for the worksheet selection change event:

-----

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' constants
Const ksTable = "DataTable"
Const ksChart = "DataChart"
Const ksGraph = "MyFansChart"
' declarations
Dim rngT As Range, rngC As Range, cht As Chart
Dim I As Integer
' start
Set rngT = Range(ksTable)
If Application.Intersect(rngT, Target) Is Nothing Then GoTo Worksheet_SelectionChange_Exit
Set cht = ChartObjects(ksGraph).Chart
' process
With Target
I = .Cells(1, .Columns.Count).Column
If .Column > 1 Then
Set rngC = Range("=OFFSET(DataTable,0,0,," & I & ")")
cht.SetSourceData Source:=rngC
Set rngC = Nothing
End If
End With
DoEvents
' end
Set cht = Nothing
Worksheet_SelectionChange_Exit:
Set rngT = Nothing
End Sub
[/pre]
-----


It's much simpler than the method described at Hui's link, I guess. Hope it was you were asking for. Just advise if any issue.


Regards!
 
Back
Top