Consulting

Results 1 to 6 of 6

Thread: Solved: How to Code to accomplish this in Excel Chart?

  1. #1
    VBAX Regular
    Joined
    Jan 2005
    Posts
    6
    Location

    Solved: How to Code to accomplish this in Excel Chart?

    I have an excel chart which shows the trend of few years data of a particular parameter. The data collected is everyday. I would like to have different x-axis interval of 1, 2, 5, 10, 15, 20, & 30 days for the total span.

    How to accomplish this using VBA?

    TIA
    GNaga

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    So you want to have a chart with 1 day intervals, then one with 2 day intervals, then one with 5 day intervals etc. and have them rotate with VBA? Or do you want to do something else?

    Can you post an attachment that shows how your data is layed out?

  3. #3
    VBAX Regular
    Joined
    Jan 2005
    Posts
    6
    Location
    Thanks for your reply.

    By creating few chart and rotating is one way of accomplishing my requirement. Is it possible to do that with one chart? I mean I will put a list box in that chart and select the interval I want.

    I have not yet created the one. I am in the brain storming session.

    GNaga

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Are you trying to do something like this?
    [vba]
    Option Explicit

    Private Sub OptionButton1_Click()

    Me.ChartObjects("Chart 1").Activate
    ActiveChart.SetSourceData _
    Source:=Sheets("Chart Data").Range("A1:B31"), PlotBy:=xlColumns

    End Sub

    Private Sub OptionButton2_Click()

    Me.ChartObjects("Chart 1").Activate
    ActiveChart.SetSourceData _
    Source:=Sheets("Chart Data").Range("D1:E16"), PlotBy:=xlColumns

    End Sub

    Private Sub OptionButton3_Click()

    Me.ChartObjects("Chart 1").Activate
    ActiveChart.SetSourceData _
    Source:=Sheets("Chart Data").Range("G1:H7"), PlotBy:=xlColumns

    End Sub
    [/vba]

    Refer to the attachment.

  5. #5
    VBAX Regular
    Joined
    Jan 2005
    Posts
    6
    Location
    Thanks for your prompt reply. Yes Your idea can be of immense help to me to start with. Without that I was confused with how to start. Now I can confidently proceed further to make it perfectly the way I want.

    Again Thanks for your time and effort.

    GNaga

  6. #6
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

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