+ Reply to Thread
Results 1 to 5 of 5

VBA XY Scatter plot vrom array does not work

  1. #1
    Registered User
    Join Date
    03-09-2009
    Location
    Delaware,Ohio
    MS-Off Ver
    Excel 2000
    Posts
    5

    VBA XY Scatter plot vrom array does not work

    This code puts a single point on my scatter plot. However the next 2 lines generate an error. How do you pass more than one X or Y value to the Set Data function in VBA?

    These lines work:
    Chart1_Series1.SetData OWC.ChartDimensionsEnum.chDimXValues, OWC.ChartSpecialDataSourcesEnum.chDataLiteral, (150)

    Chart1_Series1.SetData OWC.ChartDimensionsEnum.chDimYValues, OWC.ChartSpecialDataSourcesEnum.chDataLiteral, (200)

    These lines do not work: If I pass an array it give me an out of memory error.

    Chart1_Series1.SetData OWC.ChartDimensionsEnum.chDimXValues, OWC.ChartSpecialDataSourcesEnum.chDataLiteral, (150,100)
    Chart1_Series1.SetData OWC.ChartDimensionsEnum.chDimYValues, OWC.ChartSpecialDataSourcesEnum.chDataLiteral, (200,150)

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: VBA XY Scatter plot vrom array does not work

    Is this a continuation of your other post?

    Did you see the KB link I posted?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    03-09-2009
    Location
    Delaware,Ohio
    MS-Off Ver
    Excel 2000
    Posts
    5

    Re: VBA XY Scatter plot vrom array does not work

    I am learning more as I go so yes it is kind of a contiunuation although now I am stuck on a new trouble.

    I read your KB post but I cannot find the exact same situation and I believe that is the root of my trouble. I find similar code but not exactly a scatter plot in VBA from arrays.

    I am trying to make an XY Scatter plot via VBA Excel 2000, where the data is stored in 2 arrays, one for X values and one for Y values.

    It seems as though the SetData method will only allow 1 data value. According to the MSDN website it says I should be able to pass a one dimentional string. But I cannot seem to get it done.



    DataReference Optional Variant. For ChChart and ChSeries objects, this argument specifies the data reference as a Microsoft Excel-style range reference ("A1:D4" , for example), or a row-set column name. When the DataSourceIndex argument is set to chDataLiteral, you can set DataReference to a one-dimensional array or a comma-delimited list. For ChErrorBars objects, this argument specifies an array of Double or String values you can use for error-bar values. Note that you can use this argument only with custom error bars (the error-bar Type property must be set to chErrorBarTypeCustom).

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: VBA XY Scatter plot vrom array does not work

    Would the code not need to be

    Please Login or Register  to view this content.
    Or maybe

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-09-2009
    Location
    Delaware,Ohio
    MS-Off Ver
    Excel 2000
    Posts
    5

    Re: VBA XY Scatter plot vrom array does not work

    I tired these and they give me an error.

    The error is the "wrong number of arguments." which makes sense as everytime I try to send an array or a literal that is more than one value, it errors out.


    I have seen numerous code samples on the net that show passing an array to the setdata function. How come it will not work in VBA?

    Chris

+ 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