Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Apr 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing a Chart's Scale (1)

    I would like to change the scale properties of a chart's y axis based on cell values that are linked via DDE. These cells would not contain the data being plotted, but user defined mins and maxs. This sheet is monitoring a process via DDE and each setup has user defined mins and maxs. When the setup changes, I would like the chart to 'rescale' so the changes of process data are easy to see. I assume I can access the chart y axis scale properties somehow using VBA. Does anyone have any suggestions?

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Changing a Chart's Scale (1)

    This code snippet will change the min and max Y based on values you put into cells names minY and maxY on Chart1. change names as appropriate

    <pre> With Sheets("chart1").Axes(xlValue)
    .MinimumScale = Range("minY").Value
    .MaximumScale = Range("maxY").Value
    End With
    </pre>


    Steve

  3. #3
    New Lounger
    Join Date
    Apr 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing a Chart's Scale (1)

    Thanks Steve,
    I'm missing something because I received a subscript out of range error on the ' With...' line. I put the code in the worksheet activate sub just for test. Also I am using the Chart name that shows up in the chart monitor window when you right click and select chart window. For kicks can you humor me and show the exact syntax for 'Chart 12' on Sheet 'Test'?

  4. #4
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Changing a Chart's Scale (1)

    I assumed the chart was on a chart sheet not embedded in a worksheet

    <pre> Sheets("test").ChartObjects("Chart 12").Activate
    With ActiveChart.Axes(xlValue)
    .MinimumScale = Range("minY").Value
    .MaximumScale = Range("maxY").Value
    End With
    </pre>


    Steve

    P.S.
    TIP: Try using the macro recorder. Many of the objects and code can be learned by recording the steps and then viewing the code.

  5. #5
    New Lounger
    Join Date
    Apr 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing a Chart's Scale (1)

    Thanks , this is what I needed.

Posting Permissions

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