+ Reply to Thread
Results 1 to 17 of 17

Array limit for a macro created chart

  1. #1
    Registered User
    Join Date
    06-10-2008
    Posts
    9

    Array limit for a macro created chart

    I am working in a macro that will do some calculations and I would like to end it by plotting the results in some charts. Results are in one dimension array form, with probably more than 1000 elements. Can anybody tell me if there is any limit for the arrays that are going to be asigned to the XValues and Values of the chart?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    The limit is not the number of elements in the array but rather the length of the series formula, which is 1023
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    06-10-2008
    Posts
    9
    Andy thanks for your reply, but I dont really understand what you mean by the "series formula". Please forgive me but I am a beginer with macros.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    Select a series in your chart and in the formula bar you will see the series formula. e.g.

    =SERIES("Balance",{39600,39601,39601,39606,39606,39608,39608,39619,39619,39624,39624,39629,39629,0},{200,200,300,300,310,310,600,600,200,200,10,10,200,0},1)

    If this formula is too long the code will error.

  5. #5
    Registered User
    Join Date
    06-10-2008
    Posts
    9
    OK I understand, but what about if you asign the series directly inside a macro with arrays created by it, is it still valid?
    I ask you this because I never did it before, and now I am trying to do it but I am having porblems.
    Suppose I have the chart "ChartV" already created in a worksheet, and the arrays V() and x() calculated through a macro: how do I write the end of the macro so that it will plot the V values for each X in the ChartV?

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    If you assign arrays in code excel will automatically convert the series formula.

    Have a look at this recent post. Check Slide's example file which uses a function in a named range.
    http://www.excelforum.com/showthread.php?t=646696

  7. #7
    Registered User
    Join Date
    06-10-2008
    Posts
    9
    Thank you Andy, Ive been looking what you told me.
    I understand now what you mean by series formula, although I dont know how to assign it to the chart and dont understand how Slide does it.
    I have tried with the following code but error 438 appears:

    Please Login or Register  to view this content.

    V and x are one dimension arrays previously calculated.
    "Grafico 3" is an existing chart in "Hoja1".

    Can you help me?

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

  9. #9
    Registered User
    Join Date
    06-10-2008
    Posts
    9
    OK I am attaching an example.
    I am trying to assign to the chart in Hoja1 the values of V() and x() that come from a previous sub
    Attached Files Attached Files

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    Where is the code that calls the routine PlotV

  11. #11
    Registered User
    Join Date
    06-10-2008
    Posts
    9
    Andy
    In the meantime I tried to write the arrays to a worksheet to see results and plot from there (I have to verify macro calculations). I found some errors in the calculation and the data reading, so I have to fix them up, and afterwards I ll try to send you something "understandable".
    By the way, is the sub correct or is there any code error?
    Once again, thanks for your help.

  12. #12
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    Hard to tell as the only code I have is...

    Please Login or Register  to view this content.
    But the charts on sheet Hoja1 are called Chart 3 and Chart 4 so even with the rest of the code you still have problems.

  13. #13
    Registered User
    Join Date
    06-10-2008
    Posts
    9
    The rest of the code dont refer to the charts or charting.
    The sub is called by:
    Please Login or Register  to view this content.
    How do you get the name of the charts?

  14. #14
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    To get the names of the charts I used this in the immediate window

    Please Login or Register  to view this content.
    Do for both 1 and 2 chartobjects

    The missing code calculates the arrays, but without that I can not test anything.

  15. #15
    Registered User
    Join Date
    06-10-2008
    Posts
    9
    Sorry Andy but I dont understand what you mean to do by using that code in the "inmediate window"

  16. #16
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    When you are in the VBE (Visual basic Editor) type CTRL+G
    This will open the immediate window. This is where the results from Debug.Print are displayed.
    But you can also use it to execute commands immediately.
    The ? acts as a debug.print style command, displaying result in immediate window.

  17. #17
    Registered User
    Join Date
    06-10-2008
    Posts
    9
    Thanks for the explanation: I tried it an it resulted in Chart 3 for chartobjects (2) and Chart 4 for (1).
    I used "Grafico 3" because that was what appeared when I record a macro on it through the macro recorder.

+ 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