Consulting

Results 1 to 4 of 4

Thread: dynamic graphs

  1. #1

    dynamic graphs

    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!

    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.

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    one way.. see attached, see code by right clicking the sheet's tab and choosing 'view code'

    or a bit more elegantly:[VBA]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
    [/VBA]
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    372
    Location
    Is there a way to have the Y values selected as well based on those values?

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    [vba]With ChartObjects("Chart 1").Chart.Axes(xlValue)
    .MinimumScale = Range("C1").Value
    .MaximumScale = Range("C2").Value
    End With
    [/vba]
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •