If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Problem with .Values
Hi all,
I have a Sub for construct graphic but if the number of vx is too large, ERROR at .Values = Y. Why ? Thank you for your help, Serge Sub ConstruireGraphiqueParTableauxVBA() Dim X() As Double Dim Y() As Double, i As Long, vx As Double ReDim X(i), Y(i) Application.ScreenUpdating = False ici = ActiveSheet.Name '********************************************* For vx = -15 To 15 'If the number of vx is too large, ERROR 'at .Values = Y. Why ? '********************************************* X(i) = vx Y(i) = vx ^ 2 i = i + 1 ReDim Preserve X(i), Y(i) Next vx Charts.Add With ActiveChart .ChartType = xlXYScatter .Location Whe=xlLocationAsObject, Name:=ici End With Set ns = ActiveChart.SeriesCollection.NewSeries With ns .XValues = X .Values = Y End With Application.ScreenUpdating = True End Sub |
#2
|
|||
|
|||
Problem with .Values
Allo Serge -
You can assign an array to .Values (or .XValues), but eventually Excel converts it into a string literal in the series formula. There's a limit of around 255 characters (a little shorter, maybe 248 to 252, I used to know) for each part of the series formula. You have a few choices. Easiest is to dump the array into a worksheet range, and plot the worksheet range. Another option is to build your own literal array, limiting the significant digits in your values, as I describe near the bottom of this page: http://www.geocities.com/jonpeltier/...ChartData.html Finally, you could put the array into a defined name in the worksheet, and chart the name. You're still linked to the workbook, but not to a particular worksheet range. - Jon ------- Jon Peltier, Microsoft Excel MVP http://www.geocities.com/jonpeltier/Excel/index.html _______ garnote wrote: Hi all, I have a Sub for construct graphic but if the number of vx is too large, ERROR at .Values = Y. Why ? Thank you for your help, Serge Sub ConstruireGraphiqueParTableauxVBA() Dim X() As Double Dim Y() As Double, i As Long, vx As Double ReDim X(i), Y(i) Application.ScreenUpdating = False ici = ActiveSheet.Name '********************************************* For vx = -15 To 15 'If the number of vx is too large, ERROR 'at .Values = Y. Why ? '********************************************* X(i) = vx Y(i) = vx ^ 2 i = i + 1 ReDim Preserve X(i), Y(i) Next vx Charts.Add With ActiveChart .ChartType = xlXYScatter .Location Whe=xlLocationAsObject, Name:=ici End With Set ns = ActiveChart.SeriesCollection.NewSeries With ns .XValues = X .Values = Y End With Application.ScreenUpdating = True End Sub |
Thread Tools | |
Display Modes | |
|
|