Macro with line graph

  • Thread starter Thread starter Sasikiran
  • Start date Start date
S

Sasikiran

Dear,

I have huge data with different headers. I want to plot a single line graph
linked with a validation with the list of all the headers. The data in the
line graph should reflect only the selected header among the list.

For example, In the below example i should have a button command with the
validation list of all the three headers below apples, oranges and grapes.

By selecting oranges in the list, the line graph should pick only the data
from colA and colC.. like wise

ColA ColB ColC Cold
Row1 Time Apples Oranges Grapes
Row2 12:00 5 3 4
Row3 13:00 7 2 6
Row4 14:00 9 6 7
Row5 15:00 5 2 8
Row6 16:00 3 1 9

Please help me.
 
How about one that uses a double click on the desired column without the
need for the drop down?
Right click sheet tab>view code>insert this
Or, send your file to my address below.

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
ac = Target.Column
ms = ActiveSheet.Name

With Sheets(ms).ChartObjects(1).Chart
..SeriesCollection(1).Values = _
Range(Cells(2, ac), Cells(6, ac))
..ChartTitle.Text = Cells(1, ac)
End With
End Sub
 
Back
Top