+ Reply to Thread
Results 1 to 2 of 2

Scatter plot - macro OK - VB 6 not OK

  1. #1
    Brian Elliott
    Guest

    Scatter plot - macro OK - VB 6 not OK

    If I have 2 rows of data, say, A1 to C1 and A2 to C2 and record a macro :-

    Charts Add
    ActiveChart.ChartType = xlXYScatter
    ActiveChart.SetSourceData Source := Sheets ( " Sheet1 " ).Range ( " A1 : C2
    " ), plotby := xlrows

    This works - I get 3 pairs of co-ordinates in a graph.

    When I use the equivalent code in a VB6 program :-

    Set ch = wbook1.Charts.Add

    With ch

    ..ChartType = xlXYScatter

    ..ChartWizard Source := wsheet1.Range ( " A1 : C2 " ) , plotby := xlRows

    End With

    I get SIX separate points , 2 at x axis co-ordinate 1 , 2 more at x=2 etc.

    I have tried xlColumns, leaving the plotby out etc. but I am missing
    something very obvious I think.

    Any suggestions please.



  2. #2
    Jon Peltier
    Guest

    Re: Scatter plot - macro OK - VB 6 not OK

    Brian -

    I take it you have X values or category labels in A1:C1 and Y values in A2:C2. You
    should insert a column, so A1:C2 is shifted to B1:D2, then leave cell A1 blank and
    put a label (series name) into A2. Then use the range A1:D2 as the source data range.

    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com/
    _______

    Brian Elliott wrote:

    > If I have 2 rows of data, say, A1 to C1 and A2 to C2 and record a macro :-
    >
    > Charts Add
    > ActiveChart.ChartType = xlXYScatter
    > ActiveChart.SetSourceData Source := Sheets ( " Sheet1 " ).Range ( " A1 : C2
    > " ), plotby := xlrows
    >
    > This works - I get 3 pairs of co-ordinates in a graph.
    >
    > When I use the equivalent code in a VB6 program :-
    >
    > Set ch = wbook1.Charts.Add
    >
    > With ch
    >
    > ..ChartType = xlXYScatter
    >
    > ..ChartWizard Source := wsheet1.Range ( " A1 : C2 " ) , plotby := xlRows
    >
    > End With
    >
    > I get SIX separate points , 2 at x axis co-ordinate 1 , 2 more at x=2 etc.
    >
    > I have tried xlColumns, leaving the plotby out etc. but I am missing
    > something very obvious I think.
    >
    > Any suggestions please.
    >
    >



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1