PDA

View Full Version : dynamic graphs



dandedo2
08-23-2010, 02:19 PM
Hi, I'm certain this will be fairly straightforward for most experienced excel users, however it is something I would lose days trying to solve if I came at it with nothing! :dunno

I have a list of dates and some corresponding data, not in the adjacent column, but two colums over.

I want to have an embedded line graph which plots this data against the relevant dates, based on dates inputted into a different sheet on the work book, on the sheet where I would like the graph to appear.

Is it best to use excel formulae or vba to remedy this? The crucial aspect is that the x axis adjusts depending on which dates are input into the cells, B1 and B2 in the example sheet.

I attach an outline of the problem I have.

Any suggestions would be greatly appreciated.

Many thanks.

p45cal
08-24-2010, 01:59 AM
one way.. see attached, see code by right clicking the sheet's tab and choosing 'view code'

or a bit more elegantly:Private Sub Worksheet_Change(ByVal Target As Range)
With ChartObjects("Chart 1").Chart.Axes(xlCategory)
.MinimumScale = Range("B1").Value
.MaximumScale = Range("B2").Value
End With
End Sub

grichey
08-24-2010, 12:04 PM
Is there a way to have the Y values selected as well based on those values?

p45cal
08-24-2010, 12:14 PM
With ChartObjects("Chart 1").Chart.Axes(xlValue)
.MinimumScale = Range("C1").Value
.MaximumScale = Range("C2").Value
End With